Lucene.Net.Index.Term: Reverted to original implementation, since Utf8ToString() does not throw an exception on invalid text.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/1495bff0 Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/1495bff0 Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/1495bff0 Branch: refs/heads/master Commit: 1495bff05968258e1b24b3a1f9c0f07713ba8caf Parents: 4f0d0d1 Author: Shad Storhaug <[email protected]> Authored: Tue Apr 25 16:00:54 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Tue Apr 25 16:00:54 2017 +0700 ---------------------------------------------------------------------- src/Lucene.Net/Index/Term.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/1495bff0/src/Lucene.Net/Index/Term.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net/Index/Term.cs b/src/Lucene.Net/Index/Term.cs index 73b8407..1cf8dd7 100644 --- a/src/Lucene.Net/Index/Term.cs +++ b/src/Lucene.Net/Index/Term.cs @@ -1,5 +1,6 @@ using Lucene.Net.Support; using System; +using System.Text; namespace Lucene.Net.Index { @@ -94,10 +95,11 @@ namespace Lucene.Net.Index /// </summary> public static string ToString(BytesRef termText) { + // the term might not be text, but usually is. so we make a best effort + Encoding decoder = new UTF8Encoding(false, true); try { - // LUCENENET specific: termText already has this handy UTF8ToString method, so we're using that instead of Encoding.UTF8.GetBytes() - return termText.Utf8ToString(); + return decoder.GetString(termText.Bytes, termText.Offset, termText.Length); } catch {
