Revert "Revert "Matcher: Avoid excessive String copies.""

This reverts commit 53e4e15bb0fc2f789274998f3ce62c4fc021fbe8.

Fixes a memory leak introduced in 53e4e15bb0f. Also :
- switches to using ScopedStringChars to simplify the code further.
- better ICU error checking.

Bug: 36366255
Bug: 36818684

Test: cts -m CtsLibcoreTestCases
Test: ScannerTest on host/x86
Change-Id: I3f108931cd5236be4ff9c0bd608a87701370dbf1
3 files changed