Diacritic characters and shell CMD

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Kangaroo SW
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 35
Joined: Sat Jan 15, 2011 10:57 am

Diacritic characters and shell CMD

Post by Kangaroo SW » Sun Jun 12, 2011 1:49 pm

For a project I need to get the "Computername" of a Windows PC I use the shell CMD, but if the computername contains non ASCII chars (umlautes) I get odd characters displayed in within LiveCode.

Also, the global variable (%Computername%) from inside LiveCode does
not display non ASCII chars correctly and respects only uppercase so I can not use it.

So I try to use the CMD shell with the command "hostname", which
displays the name correctly in the commandline window but not inside LiveCode.

I made a little script wich replaces the odd chars but there must be a better way !
After reading the use-list and the Forum up and down I have give up :oops: , can anyone help :lol: ?

Code: Select all

on mouseUp
   set hideConsoleWindows to true
   put empty into varComputerName
   
   --••  use the shell to get the computername, this returns Ԑ·Š‚…™šŽ”„ for ÈÉÀèéàÖÜÄöüä
   put shell("hostname") into varComputerName
   
   --••  replace chars to get the correct characters
   replace "Ô" with "È" in varComputerName
   replace "" with "É" in varComputerName
   replace "·" with "À" in varComputerName
   
   replace "Š" with "è" in varComputerName
   replace "‚" with "é" in varComputerName
   replace "…" with "à" in varComputerName
   
   replace "™" with "Ö" in varComputerName
   replace "š" with "Ü" in varComputerName
   replace "Ž" with "Ä" in varComputerName
   
   replace "”" with "ö" in varComputerName
   replace "" with "ü" in varComputerName
   replace "„" with "ä" in varComputerName
   
   answer varComputerName
end mouseUp


Cheers Rolf

Klaus
Posts: 13853
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Diacritic characters and shell CMD

Post by Klaus » Sun Jun 12, 2011 3:48 pm

Hi Rolf,

well, the problem is the non-standard character encoding of the Windows shell (no surprise really :D )
Unfortunately I have no idea wha encoding is being used here, at least this is obviously not standard LATIN-ISO-whatever!


Best

Klaus

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Diacritic characters and shell CMD

Post by shaosean » Sun Jun 12, 2011 5:00 pm

This is an interesting read and may help you out, but remember that Rev does not handle Unicode all that well (at all?) coming from the OS (for example file paths)..

http://stackoverflow.com/questions/1259 ... -exe-using

Kangaroo SW
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 35
Joined: Sat Jan 15, 2011 10:57 am

Re: Diacritic characters and shell CMD

Post by Kangaroo SW » Sun Jun 12, 2011 7:29 pm

Thank's Klaus and shaosean

This means that my poor mans handler will be the only solution to my problem, for now :roll: ?!

Or is there an other way to get the computername in Windows ?

Cheers
Rolf

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Diacritic characters and shell CMD

Post by shaosean » Mon Jun 13, 2011 1:05 am

You could always build an external, but you would have the same issue as Rev does not handle Unicode there either..

RRobert
Posts: 151
Joined: Sat Feb 28, 2009 8:20 pm

Re: Diacritic characters and shell CMD

Post by RRobert » Mon Jun 13, 2011 9:19 pm

You could query HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName.

Robert

Post Reply

Return to “Windows”