[dev] [surf] OT JSStringRef to stdout

From: Christian Hahn <ch_AT_radamanthys.de>
Date: Mon, 23 Aug 2010 17:54:35 +0200


I want to print a possible exception in function *runscript* to stdout,
but I have a problem with this JSStringRef.

What I currently do is:

if (fwide(stdout, 1) >0) .....

JSStringRef str = JSStringCreateWithUTF8CString("test");

const JSChar *c = JSStringGetCharactersPtr(str);
for(int i=0; i<JSStringGetLength(str); i++) {
        wprintf(L"%s", c); c++;

because wprintf(L"%s", JSStringGetCharactersPtr(str) )
just prints the first character or gibberish with "%ls".
Same, if I don't use wide mode and just printf.
It always prints only the first character.

So, what's the right way?

Received on Mon Aug 23 2010 - 17:54:35 CEST

This archive was generated by hypermail 2.2.0 : Mon Aug 23 2010 - 18:12:02 CEST