Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTF8/16 /Unicode to proper manange asian charactors #334

Open
LukyGuyLucky opened this issue May 6, 2024 · 4 comments
Open

UTF8/16 /Unicode to proper manange asian charactors #334

LukyGuyLucky opened this issue May 6, 2024 · 4 comments

Comments

@LukyGuyLucky
Copy link

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.

@ghost
Copy link

ghost commented May 6, 2024

Keep your source files in UTF-8 (without BOM) and type the Unicode characters as normal. I think it will work.

@IsaacShelton
Copy link
Collaborator

@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)
}

https://github.com/IsaacShelton/AdeptAsianText

@LukyGuyLucky
Copy link
Author

LukyGuyLucky commented May 9, 2024

Thanks both.It works.

But when the text filename is with ansia charactor say 汉字.txt,then the program will fail to read.

@IsaacShelton
Copy link
Collaborator

IsaacShelton commented May 9, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants