Message board for the users of flat assembler.
> Windows > How do I print unicode string using printf
Goto page Previous 1, 2
Flier-Mate 10 Jun 2023, 09:28
Thanks for the file, bitRAKE.
So it confirms that only Windows 11 is able to display multi-lingual string in UTF-8 codepage. Mine is Windows 10 and only Greek is OK.
I have to shut down my Windows Defender or else it refused to download your attachment.
Another user from local forum reports "works fine with Windows termincal, fonts cascadia mono, lucida console" to display Hindi on his/her Windows 11 (Windows 10.0.22631.1830). So I think font rendering in Windows 11 is automatic.
|10 Jun 2023, 09:28||
revolution 10 Jun 2023, 10:18
Your screenshot shows it working fine, with the only issue that your chosen font doesn't have the glyphs to render the characters. Those squares are what most font renderers will show when the glyph isn't found in the font.
Win7 could do this when you have the right font available, so I see no reason that Win10 can't. All you need to do is choose a different font with the glyphs you use.
|10 Jun 2023, 10:18||
moistMaven 11 Jun 2023, 10:36
I use the same code that I posted above, but no luck seeing Hindi characters in my Windows 10 console.
Setting the Code Pages inside of assembly works but not directly in console, I don't know why?
format PE console entry start include "win32a.inc" include "encoding\utf8.inc" section ".data" data readable writeable hindi du "हिन्दी",13,10,0 _len = $ - hindi section ".code" code executable readable start: ccall [SetConsoleOutputCP], 65001 push -11 call [GetStdHandle] push 0 push 0 push _len push hindi push eax call [WriteConsoleW] push 0 call [ExitProcess] ;==================================== section '.idata' import data readable ;==================================== library kernel,'kernel32.dll', msvcrt,'msvcrt.dll' import kernel, SetConsoleOutputCP, 'SetConsoleOutputCP', \ GetStdHandle, "GetStdHandle", \ WriteConsoleW, "WriteConsoleW", \ ExitProcess, "ExitProcess" import msvcrt, printf,'printf', getchar,'_fgetchar'
|11 Jun 2023, 10:36||
bitRAKE 11 Jun 2023, 12:36
... the encoding file determines how fasm[g] interprets bytes when forming WCHAR characters and defines macros for DU type string composed of WCHARs.
Which is completely unrelated to SetConsoleOutputCP.
... setting the code page has no effect when using the W family of console APIs.
UTF-8 formatted text can be sent to the A family of console APIs after ensuring the code page is first set to 65001 (CP_UTF8) with the SetConsoleCP and SetConsoleOutputCP functions.
Using include "encoding\utf8.inc" is not needed when using the A family of console APIs with UTF-8 encoding characters.
They are mutually exclusive. Either one is sending bytes to the A family of console APIs with UTF-8 encoding characters, or one is sending WCHARs to the W family of console APIs.
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
|11 Jun 2023, 12:36||
|Goto page Previous 1, 2
< Last Thread | Next Thread >
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.