how to test if a string is a valid UTF16 string?
Posted
by superb
on Stack Overflow
See other posts from Stack Overflow
or by superb
Published on 2010-05-23T08:42:18Z
Indexed on
2010/05/23
8:50 UTC
Read the original article
Hit count: 243
I am using mongodb and javascript to do some string processing. Now I got some error like:
Sun May 23 07:42:20 Assertion failure JS_EncodeCharacters( _context , s , srclen , dst , &len) scripting/engine_spidermonkey.cpp 152 0x80f4f7e 0x80f8794 0x811525b 0x811a953 0x8119fc4 0x8111bc5 0x81b408e 0x81c4ee7 0x81b4a10 0x817a881 0x817a7d8 0x817a6e2 0x811e1bb 0x80a777b 0x80a8f8a 0xb7cb2455 0x80a37a1 mongodb-linux-i686-1.4.2/bin/mongo(_ZN5mongo12sayDbContextEPKc+0xfe) [0x80f4f7e]
After doing some google, I find that JS_EncodeCharacters return false if the input is not a valid UTF16 string. (if spidermonkey is build with UTF-8 enabled)
So I was wondering how to test if the input string if a proper UTF16 string? so I can skip such kind of string to avoid problem ...
Thanks
© Stack Overflow or respective owner