Hello everyone, I want to know how do I print foreign letters?
For example, I got file, which is in Cyrillic letters, and I need to get and write its name, but unfartunatelly I can't, it keeps writing squares.
Do you know how to write in foreign characters?
Please, I really need it.
Display foreign letters
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Display foreign letters
If you use utf-8 it should Just Work™, that is, if your font contains those characters.
Re: Display foreign letters
It does contain it, but when I try to print some of cyrillic letters (string.char(128) returns "A" in cyrillic), it return UTF-8 error.
Re: Display foreign letters
Must be issues with font loaded by default.
- Attachments
-
- datafile.love
- (158.54 KiB) Downloaded 189 times
Re: Display foreign letters
I've downloaded your file, and I can what is written there.raidho36 wrote:Must be issues with font loaded by default.
But problem is when I try to get file name which is in Cyrillic, and when I try to display that name of the file, it gives me utf-8 error. UTF-8 error will also appear if I will write string.char(128) (Letter "A" in Russian in correct font)
I need to get rid of that error.
Re: Display foreign letters
On Windows, the console is using one of the local code pages instead of an UTF encoding by default. In your case, this is probably code page 866. So if you write print("\128") it is obvious that the console interprets that as 'А'. However, the LÖVE API expects you to encode this in UTF-8 which would be "\208\144".
If you have a proper text editor, it should allow you to encode your files in UTF-8 (without the BOM).
The LÖVE API itself returns UTF-8 strings. If you get the file name through love.filesystem, it should work automatically.
If you have a proper text editor, it should allow you to encode your files in UTF-8 (without the BOM).
The LÖVE API itself returns UTF-8 strings. If you get the file name through love.filesystem, it should work automatically.
Shallow indentations.
Re: Display foreign letters
But I can't get outside of .love archieve using love.filesystem.
Please tell me is it possible at all?
Please tell me is it possible at all?
Re: Display foreign letters
OK, I've solved it. Thanks everyone who replied here.
So in order to get and print file name in foreign letters you have to:
1. Create a dummy file (and make its name same as the file you wanted to print) in your save directory using standard io library.(E.G. %appdata%/YOURGAME/tmp/)
2. Get its name using love.filesystem.enumerate()
3. Remove the dummy file using love.filesystem.remove().
4. Print the name you get.
Working fine for me! And again, thank you everyone!
So in order to get and print file name in foreign letters you have to:
1. Create a dummy file (and make its name same as the file you wanted to print) in your save directory using standard io library.(E.G. %appdata%/YOURGAME/tmp/)
2. Get its name using love.filesystem.enumerate()
3. Remove the dummy file using love.filesystem.remove().
4. Print the name you get.
Working fine for me! And again, thank you everyone!
Who is online
Users browsing this forum: Bing [Bot] and 7 guests