On Fri, Aug 19, 2011 at 2:40 PM, Mikhail <[email protected]> wrote: > And it works fine for codes less than 128, 'cause it match with ASCII, > but there is a problem with codes from interval [128, 255] it could > take from 1 to 4 bytes. >
You're apparently appending the bytes one at a time to a String object? (i'm guessing.) > Is it possible to build string where 1 char = 1 byte and char codes > are from the interval [0, 255]? > Do you have any idea? > ASCII and UTF have no 1-byte characters above 127 (latin1 and many other encodings do), and the v8::String ctor requires (if i'm not sorely mistaken) that the bytes be ASCII/UTF8. Yes, a byte can hold 255 values but neither ASCII nor Unicode uses 128..255 (see the chart at http://www.utf8-chartable.de/). So you're going to need to convert your bytes to UTF8 before turning them into v8-compatible strings. If you don't already have code for doing so i can _highly_ recommend the utf8cpp: http://utfcpp.sourceforge.net/ it's header-only, liberally licensed, and iterator-based, making it easy to convert between utf8/16 using many types of storage (not just a single string class, e.g. std::string). (i'm not a member of the project, just a user, by the way.) -- ----- stephan beal http://wanderinghorse.net/home/stephan/ -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
