Commit 9eda05c2 authored by miloyip's avatar miloyip

Fixes example code in encoding

parent 7cfe718d
...@@ -130,8 +130,17 @@ const char* s = "..."; // UTF-8 string ...@@ -130,8 +130,17 @@ const char* s = "..."; // UTF-8 string
StringStream source(s); StringStream source(s);
GenericStringBuffer<UTF16<> > target; GenericStringBuffer<UTF16<> > target;
Transcoder::Transcode<UTF8<>, UTF16<> >(source, target) bool hasError = false;
const wchar_t* t = target.GetString(); 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. You may also use `AutoUTF` and the associated streams for setting source/target encoding in runtime.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment