diff options
author | miloyip <miloyip@gmail.com> | 2014-07-16 05:13:06 +0400 |
---|---|---|
committer | miloyip <miloyip@gmail.com> | 2014-07-16 05:13:06 +0400 |
commit | 9eda05c2862c600fd65d15e24b50a2bede70644e (patch) | |
tree | df4ad77806f83f00b8df9832ec142b172161f248 /doc | |
parent | 7cfe718d3d1abbb15676b8f83e001b00eb2f1473 (diff) |
Fixes example code in encoding
Diffstat (limited to 'doc')
-rw-r--r-- | doc/encoding.md | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/doc/encoding.md b/doc/encoding.md index bc5c178f..4d7ca7bc 100644 --- a/doc/encoding.md +++ b/doc/encoding.md @@ -130,8 +130,17 @@ const char* s = "..."; // UTF-8 string StringStream source(s); GenericStringBuffer<UTF16<> > target; -Transcoder::Transcode<UTF8<>, UTF16<> >(source, target) -const wchar_t* t = target.GetString(); +bool hasError = false; +while (source.Peak() != '\0') + if (!Transcoder::Transcode<UTF8<>, 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. |