From: Park Heesob Date: 2007-11-10T22:33:55+09:00 Subject: Re: non-English path problem Hi, ----- Original Message ----- From: "Amanda Fae" Newsgroups: comp.lang.ruby To: "ruby-talk ML" Sent: Saturday, November 10, 2007 5:27 PM Subject: non-English path problem > I've been stumped on this problem for days and I have a feeling that it > is really simple... > > I am trying to create a folder at the following location: > C:\documents and settings\[username]\application data\amaranth > > The following code works great unless the username has a non-English > character in it (for example, JoƩ). In this case, when I try to use the > path, I get a "path not found" error, and it says that the path is: > C:\documents and settings\Jo\application data\amaranth > > From what I can see, my code is striping out any non-English characters. > I'm not quite sure how to get these non-English characters to show up. > > Here is my code: > > ------------------------------------ > > SHGetFolderPath = > Win32API.new("shell32.dll","SHGetFolderPathW",["P","I","P","I","P"],"I") > > path = " " * 256 > > SHGetFolderPath.call(0,0x001A,0,0,path) > > $appPath = path.strip.gsub("\000","") + "\\amaranth" > > ------------------------------------ > > Does anyone have any idea what I'm doing wrong? I'm pretty new at this > so if you can be as non-technical as possible, I would appreciate it. > > :) > > Amanda > -- You should convert widechar string to multibyte string with WideCharToMultiByte API. Try this code: SHGetFolderPath = Win32API.new("shell32.dll","SHGetFolderPathW",["P","I","P","I","P"],"I") WideCharToMultiByte = Win32API.new('kernel32', 'WideCharToMultiByte', 'ILPIPIPP', 'I') path = "\0" * 256 buf="\0"*256 SHGetFolderPath.call(0,0x001A,0,0,path) WideCharToMultiByte.call(0,0,path,-1,buf,256,0,0) $appPath = buf.strip + "\\amaranth" Regards, Park Heesob