From 9eda05c2862c600fd65d15e24b50a2bede70644e Mon Sep 17 00:00:00 2001 From: miloyip Date: Wed, 16 Jul 2014 09:13:06 +0800 Subject: [PATCH] Fixes example code in encoding --- doc/encoding.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/encoding.md b/doc/encoding.md index bc5c178..4d7ca7b 100644 --- a/doc/encoding.md +++ b/doc/encoding.md @@ -130,8 +130,17 @@ const char* s = "..."; // UTF-8 string StringStream source(s); GenericStringBuffer > target; -Transcoder::Transcode, UTF16<> >(source, target) -const wchar_t* t = target.GetString(); +bool hasError = false; +while (source.Peak() != '\0') + if (!Transcoder::Transcode, UTF16<> >(source, target)) { + hasError = true; + break; + } + +if (!hasError) { + const wchar_t* t = target.GetString(); + // ... +} ~~~~~~~~~~ You may also use `AutoUTF` and the associated streams for setting source/target encoding in runtime.