Open LukyGuyLucky opened 3 months ago
Keep your source files in UTF-8 (without BOM) and type the Unicode characters as normal. I think it will work.
@LukyGuyLucky Yes as iahung2 described, even though it isn't officially supported, you can sometimes get away with just putting it in the text.
If you want to be sure though, you can use embed
to include file contents at compile-time as a String
, and then use them like normal:
asian.txt
汉字山한글乇乂丅尺卂たくさんあったけれど時間ることができ
main.adept
import basics
foreign SetConsoleOutputCP(uint) int
define CP_UTF8 = 65001
func main {
#if __windows__
SetConsoleOutputCP(CP_UTF8)
#end
text String = embed "asian.txt"
print(text)
}
Thanks both.It works.
But when the text filename is with ansia charactor say 汉字.txt,then the program will fail to read.
Yes, using non-ascii characters in the code itself is not officially supported
Since Windows uses a different encoding scheme for filenames, that's why it does not work on Windows. (I tried cross-compiling it to Windows from macOS and works, so this is specific to the Windows filesystem)
main.adept:12:19: error: Failed to read file '汉字.txt'
12| text String = embed "汉字.txt"
^^^^^
Feel free to make a PR though if you like
Also, this issue will be taken care of and non-latin characters will be fully supported in Adept 3.0 once it comes
Thanks for the great lanaguage!
I would like to read/write asain charaters(files) with this lanaguage either with GUIs or in terminals under Windows 10 64 bit.Is it possible ?
Thanks and best regards.