The internal storage format for strings are either ASCII (one byte per char) or UTF-16 (two bytes per string). So any UTF-8 string which has only ASCII characters is stored as ASCII otherwise UTF-8 is converted to UFT-16. The fact that there is no uint16_t version of NewSymbol in the API is mainly because no-one has added it.
Regards, Søren On Mon, Jan 3, 2011 at 14:10, JBaron <[email protected]> wrote: > Thanks for the reply (I was already afraid of having to do that extra > step if there is no way to construct it using a utf-16 string). > > Just out of curiosity, does that also imply that the internal storage > format of the V8 symbol is also UTF-8? > > When I read a previous posting, it had some performance figures of > what was the quickest way to instantiate a String in V8. The uint16_t > variant always won in that example. So I just assumed this was the > internal format for Strings and then more assumptions on my site, I > also assumed it to be the internal format for Symbols. > > regards, > > Peter > > On Jan 3, 11:05 am, Søren Gjesse <[email protected]> wrote: > > The String::NewSymbol(const char*, int) takes a utf-8 encoded string like > > the String::New(const char*, int), so you will need to encode your > Unicode > > string into utf-8. > > > > Regards, > > Søren > > > > > > > > On Sun, Jan 2, 2011 at 18:01, JBaron <[email protected]> wrote: > > > After recently got a better understanding of how property setters and > > > getters work within V8 (thanks to this list), I thought it might be a > > > good idea to revise a XML/HTML5 parser I created some time ago. > > > > > When the parser returns an attribute name to the JavaScript > > > environment I used code like this to fill an array: > > > > > result2->Set(counter++,String::New(&sc->value2[0])); > > > > > result2 being an simple Array::New() and sc->value2 a standard C++ > > > Vector of the type uint16_t. So straight forward returning an array > > > with some strings supporting unicode. So I thought I just change > > > String::New to String::NewSymbol and I'm done. However I found out > > > that the NewSymbol constructor doesn't support uint16_t. > > > > > Does anyone know how do I create a "unicode" capable symbol? > > > > > Thanks in advance!!! > > > > > regards, > > > > > Peter > > > > > -- > > > v8-users mailing list > > > [email protected] > > >http://groups.google.com/group/v8-users- Hide quoted text - > > > > - Show quoted text - > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users > -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
