Jump to content

Is there a reason ConsoleWrite converts everything to ANSI and doesn't support Unicode?


VAN0
 Share

Recommended Posts

I guess it's for historic reasons.

BTW, I use my function CW() instead, which works in compiled programs as well:

Func CW($s = "")
    If @Compiled Then
        _CUI_ConsoleWrite($s)
    Else
        _ConsoleWrite($s)
    EndIf
EndFunc   ;==>CW


Func _CUI_ConsoleWrite(ByRef $s)
    Local Static $hDll = DllOpen("kernel32.dll")
    Local Static $hCon = __CUI_ConsoleInit($hDll)
    DllCall($hDll, "bool", "WriteConsoleW", "handle", $hCon, "wstr", $s & @LF, "dword", StringLen($s) + 1, "dword*", 0, "ptr", 0)
    Return
EndFunc   ;==>_CUI_ConsoleWrite


; internal use only
Func __CUI_ConsoleInit(ByRef $hDll)
    DllCall($hDll, "bool", "AllocConsole")
    Return DllCall($hDll, "handle", "GetStdHandle", "int", -11)[0]
EndFunc   ;==>__CUI_ConsoleInit


; Unicode-aware ConsoleWrite
Func _ConsoleWrite(ByRef $s)
    ConsoleWrite(BinaryToString(StringToBinary($s & @LF, 4), 1))
EndFunc   ;==>_ConsoleWrite

 

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)

Link to comment
Share on other sites

$s = BinaryToString(StringToBinary(ChrW(0x2705), $SB_UTF8), $SB_UTF8)
CW($s)

 

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)

Link to comment
Share on other sites

OK, so my console writes this

>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\AutoIt\unicode\write_unicode.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
✅
+>08:45:57 AutoIt3.exe ended.rc:0
+>08:45:57 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 1.032

Now I am guessing that the console output and file EXE may display different results...

 

So (a) should I change the Console output? Or should I just test with display (like in msgbox)

My Msgbox displays 0

MsgBox(0,"Unicode",CW($s))

 

Skysnake

Why is the snake in the sky?

Link to comment
Share on other sites

To display Unicode in the Scite console you need to switch it to UTF8 and select a Unicode-aware display font. I recommend DéjàVu Sans Mono: it's very unambiguous and covers a fair part of Unicode. No available font covers all of Unicode!

 

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)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...