caseih wrote:SHELL takes a normal string as a parameter and calls the C runtime system() function, which is the ANSI version. So passing any WSTRING or unicode literal to SHELL is going to get converted to ANSI (whatever 8-bit character set your Windows is set to use).
I wish FB would do that; but apparently, even a perfectly valid 8-bit character set like "UTF-8" is being garbled:
Code: Select all
#include "Windows.bi"
Function Utf8String(src as wstring) as String
Dim As integer slen=Len(src)
Dim As String sret=String(slen*2, 0)
slen=WideCharToMultiByte(65001, 0, @src, -1, sret, 0, 0, 0)
WideCharToMultiByte(65001, 0, @src, -1, sret, slen, 0, 0)
return sret
End Function
shell("chcp 65001")
Dim ws As wString*100="cmd.exe /C echo Добро пожаловать > Добро.txt"
Dim s As String=Utf8String(ws)
' asm int 3
' asm mov eax, [s] ' this is a perfectly valid UTF-8 string!
print s
shell(s)
Sleep()
Neither print nor shell use this string "as is".