FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[bug] Wide character for Chinese

 
Post new topic   Reply to topic     Forum Index -> Visual D
View previous topic :: View next topic  
Author Message
sdv



Joined: 20 May 2006
Posts: 2

PostPosted: Sun Dec 04, 2011 12:48 pm    Post subject: [bug] Wide character for Chinese Reply with quote

string2OLESTR(mFilename)

"mFilename" Does not support Chinese
Back to top
View user's profile Send private message
sagitario



Joined: 03 Mar 2007
Posts: 292

PostPosted: Mon Dec 05, 2011 12:10 pm    Post subject: Reply with quote

I guess you mean that you cannot add a file with a chinese name to a project. As strings are UTF in D and OLESTR is a wide character string, I would expect it should be working. Could you give an example?
Back to top
View user's profile Send private message
sdv



Joined: 20 May 2006
Posts: 2

PostPosted: Thu Dec 08, 2011 2:17 am    Post subject: Reply with quote

Code:

string str1;
// chinese for Ansi
//str1 = "\xd5\xe2\xca\xc7\xd6\xd0\xce\xc4";
// chinese for utf-8
str1 = "\xe8\xbf\x99\xe6\x98\xaf\xe4\xb8\xad\xe6\x96\x87";

wchar* string2OLESTR(string s)
{
   wstring ws = toUTF16(s);
 //UTF-8 error  ws.length = 4
// Ansi Program exit.
   int sz = (ws.length + 1) * 2;
   wchar* p = cast(wchar*) CoTaskMemAlloc(sz);
   //wchar p[];
   p[0 .. s.length] = ws[0 .. $];
   p[s.length] = 0;
   return p;
}



"ws" the return value it not looking forward
Back to top
View user's profile Send private message
sagitario



Joined: 03 Mar 2007
Posts: 292

PostPosted: Thu Dec 08, 2011 3:21 pm    Post subject: Reply with quote

Thanks for pointing it out. The fix will be in the next release:

Code:

wchar* string2OLESTR(string s)
{
   wstring ws = toUTF16(s);
   int sz = (ws.length + 1) * 2;
   wchar* p = cast(wchar*) CoTaskMemAlloc(sz);
   p[0 .. ws.length] = ws[0 .. $];
   p[ws.length] = 0;
   return p;
}


Your string after the comment "chinese for Ansi" is not a valid utf8 string. Did you mean it as a wstring?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Visual D All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group