Status: New
Owner: ----

New issue 3275 by [email protected]: Can V8 Engine handle chinese?
http://code.google.com/p/v8/issues/detail?id=3275

hi there,

I found the v8 engine cannot handle chinese, take the code below for example, it is expected return and output "你好", but in fact, it returns some garbage like "锟斤拷锟斤拷", could anyone help me about this issue? Thanks in advance.

int _tmain(int argc, _TCHAR* argv[])
{
 Isolate* isolate = Isolate::GetCurrent();
 HandleScope handle_scope(isolate);
 Handle<Context> context = Context::New(isolate);
 Context::Scope context_scope(context);
 CString temp = "'你'+'好'";
String::Utf8Value mergeResult(ExecuteJs(isolate,ConvertUnicodeToAnsi(temp.GetBuffer())));
 cout<<*mergeResult<<endl;
 return 0;
}

char* ConvertUnicodeToAnsi(wchar_t* source)
{
  int nLength = 0;
  nLength = ::WideCharToMultiByte(CP_ACP,0,source,-1,NULL,0,NULL,NULL);
  char* chars = new char[nLength + 1];
::WideCharToMultiByte(CP_ACP,0,source,wcslen(source) + 1,chars,nLength,NULL,NULL);
  return chars;
}

Handle<Value> ExecuteJs(Isolate* isolate, const char* code)
{
  Handle<String> source = String::NewFromUtf8(isolate, code);
  Handle<Script> script = Script::Compile(source);
  Handle<Value> result = script->Run();
  return result;
}


--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to