Jump to content
Jakub-M

Diacritical characters replaced/deleted in string

Recommended Posts

Jakub-M

Hi I am from slovakia, autoit is wonderfull, but when I create slovakian scripts/applications, that autoit not accept slovakian alphabeticaly extended characters ľ,č,ť.... even, in default, this is unable to be writen or diacritical mark on characters is missing after writing to editor.

It can be resolved by opening file in notepad, and saved in UTF-8 encoding, but:

For example, I want get netsh adapters, (adapter names for use with netsh command)

I run "netsh interface show interface" in Run() in cmd

Then I read CMD window by PID:

$cmdline=StdoutRead($PID2)

But sometimes adapter name contains diacritics, for example:

"Lokálne pripojenie"

$cmdline string contain "Lok lne pripojenie" simply, á character is replaced by spacebar.

I tried to rename my adapter and use name: "Lokálne pripojenie ľščťžýáíéóú"

$cmdline after this contains "Lok lne pripojenie –çźś§ě ˇ‚˘Ł"

Is some way to resolve this, or solution is not exist for autoit?

Such problems with diacritics in autoit is more.

Tkanks

 

 

Share this post


Link to post
Share on other sites
jchd

You're capturing stdout from CMD, which uses the default codepage defined by your system settings.
What does "chcp" return when run in a CMD window?
Try to change default CMD charset to Unicode before running netsh. Use "chcp 65001" to switch console to UTF8. You should then capture UTF8 strings.

Store the file below and run "type utf8.txt" in a console under that directory. You'll see weird-looking text. Now run "chcp 65001" and then "type utf8.txt" to see the difference.

utf8.txt

Note that the chinese text won't show correctly unless you have the Windows asian charsets extension installed.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
Jakub-M

thanks

"chcp" return: Active code page: 852

when i use code page 65001 then read from stdout:

Lokálne pripojenie ľščťžýáíéóú


still no good, I tested other pagesets and not working

Share this post


Link to post
Share on other sites
jchd

The UTF8 you read from stdout needs to be converted to UTF16-LE which AutoIt uses.

Try this:

; $s is your UTF8 string
Local $Str = BinaryToString(StringToBinary($s, 4), 1)

EDIT: exchange 4 and 1 as noticed by OP. Sorry for mistake.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
Jakub-M

I use

Local $Str = BinaryToString(StringToBinary($s, 1), 4)

change 4 and 1 instead of your hint code and it works properly

Question is, how encoding is used for stdoutread returned text, because I must use charset 65001 for cmd and flag 1 in StringToBinary()

Share this post


Link to post
Share on other sites
Zedna

@Jakub

Look here 

My Examples using this Ansi2Oem and Oem2Ansi conversion:

EDIT:

General explanation: In GUI is used ANSI codepage (1250 in Czech) and in CUI commandline is used OEM codepage (852 in Czech)

 

PS: I'm from Czech republic ;-)

Edited by Zedna

Share this post


Link to post
Share on other sites
jchd

GUI uses Unicode in Windows since ... long time ago.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×