我在使用FASM(Flat Assembler)中的wprintf函数打印Unicode字符串时遇到问题。
我尝试了以下代码,但它产生随机输出(αñ αñ αñ¿ αÑìαñ┐):
format PE64 console
entry start
include './include/win64w.inc'
include './include/macro/proc64.inc'
include './include/encoding/utf8.inc'
;======================================
section '.data' data readable writeable
;======================================
;unicode for हिन्दी
wunicode_string dw 0xe0, 0xa4, 0xb9, 0xe0, 0xa4, 0xbf, 0xe0, 0xa4, 0xa8, 0xe0, 0xa5, 0x8d, 0xe0, 0xa4, 0xbf
;=======================================
section '.code' code readable executable
;=======================================
start:
mov rax, 0
ccall [wprintf], "%ls", wunicode_string
ccall [getchar] ; I added this line to exit the application AFTER the user pressed any key.
stdcall [ExitProcess],0 ; Exit the application
;====================================
section '.idata' import data readable
;====================================
library kernel,'kernel32.dll', msvcrt,'msvcrt.dll'
import kernel, ExitProcess,'ExitProcess'
import msvcrt, printf,'printf', wprintf, 'wprintf', getchar,'_fgetchar'
1条答案
按热度按时间wwtsj6pe1#
如果我们为控制台设置正确的code page,它会显示正确的输出,我们可以在FASM中这样做(也可以在NASM中工作),如下所示:
我用过
printf
,但它也适用于wprintf
。