Display foreign letters

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Factis
Prole
Posts: 14
Joined: Sun Sep 23, 2012 5:38 pm

Display foreign letters

Post by Factis »

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.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Display foreign letters

Post by bartbes »

If you use utf-8 it should Just Work™, that is, if your font contains those characters.
Factis
Prole
Posts: 14
Joined: Sun Sep 23, 2012 5:38 pm

Re: Display foreign letters

Post by Factis »

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.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Display foreign letters

Post by raidho36 »

Must be issues with font loaded by default.
Attachments
datafile.love
(158.54 KiB) Downloaded 189 times
Factis
Prole
Posts: 14
Joined: Sun Sep 23, 2012 5:38 pm

Re: Display foreign letters

Post by Factis »

raidho36 wrote:Must be issues with font loaded by default.
I've downloaded your file, and I can what is written there.

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.
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Display foreign letters

Post by Boolsheet »

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.
Shallow indentations.
Factis
Prole
Posts: 14
Joined: Sun Sep 23, 2012 5:38 pm

Re: Display foreign letters

Post by Factis »

But I can't get outside of .love archieve using love.filesystem.
Please tell me is it possible at all?
Factis
Prole
Posts: 14
Joined: Sun Sep 23, 2012 5:38 pm

Re: Display foreign letters

Post by Factis »

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!
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests