Hey everyone! I'd like some help in regards to non-utf8 characters. Just to start, I'm making a Mari0 mod which adds non-utf8 characters. It used to work flawlessly on the 0.8.0 version, when love.keypressed had the "unicode" argument. However, we all know it was since removed on 0.9.x, and replaced by love.textinput. The problem is that it doesn't seem to work for some non-utf8 characters, and trying to get the unicode via string.byte doesn't work either, as most non-utf8 characters, for some reason, return the same value. I managed to get some characters working properly, but a lot of them simply don't work at all, as the key argument in love.keypressed is "unknown" and the character I get via love.textinput is completely unrelated.
tl;dr: I'd love if someone could help me get with coding for something similar to the "unicode" argument from love.keypressed in Löve 0.8.0, but in 0.9.x instead. Thanks in advanced
EDIT: If necessary, I can provide a download link to the mod.
Unicode and non-utf8 characters
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- HugoBDesigner
- Party member
- Posts: 403
- Joined: Mon Feb 24, 2014 6:54 pm
- Location: Above the Pocket Dimension
- Contact:
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Unicode and non-utf8 characters
I'm not sure what you mean by "non-utf8" characters, since utf8 can represent all unicode characters.
As for replacing the unicode argument, love.textinput is better in every way, and is much easier to use to boot.
As for replacing the unicode argument, love.textinput is better in every way, and is much easier to use to boot.
- HugoBDesigner
- Party member
- Posts: 403
- Joined: Mon Feb 24, 2014 6:54 pm
- Location: Above the Pocket Dimension
- Contact:
Re: Unicode and non-utf8 characters
By "non-utf8" characters I mean characters that aren't supported by default and require libraries such as [wiki]utf8[/wiki] to run it. This is what I was using on the LÖVE 0.8.0 version of the mod, but it doesn't work anymore on 0.9.x, as we don't have the key unicode anymore.
Some examples of non-utf8 characters: " áàâãäçéèêëéèêëñóòôõöúùûüÁÀÂÃÄÇÉÈÊËÍÌÎÏÑÓÒÔÕÖÚÙÛÜßẞ " (took from my own code, pretty handy)
Some examples of non-utf8 characters: " áàâãäçéèêëéèêëñóòôõöúùûüÁÀÂÃÄÇÉÈÊËÍÌÎÏÑÓÒÔÕÖÚÙÛÜßẞ " (took from my own code, pretty handy)
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Unicode and non-utf8 characters
You mean non-ASCII characters. As bartbes said, a non-utf8 character would be a non-unicode character.HugoBDesigner wrote:By "non-utf8" characters I mean characters that aren't supported by default and require libraries such as [wiki]utf8[/wiki] to run it.
Help us help you: attach a .love.
- HugoBDesigner
- Party member
- Posts: 403
- Joined: Mon Feb 24, 2014 6:54 pm
- Location: Above the Pocket Dimension
- Contact:
Re: Unicode and non-utf8 characters
Yeah, non-ASCII characters is what I meant. Do you think it can be worked around in 0.9.x? According to the wiki page, the utf8 library doesn't works properly in the 0.9 versions...
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Unicode and non-utf8 characters
Okay, from your post, I think you want utf8.codepoint, to turn an encoded character as received by love.textinput into a numerical codepoint.
What do you use the codepoint for? Because as long as you don't need to pass it into utf8.char, it should be alright, because that's the only function not working correctly in 0.9.2.
What do you use the codepoint for? Because as long as you don't need to pass it into utf8.char, it should be alright, because that's the only function not working correctly in 0.9.2.
Help us help you: attach a .love.
- HugoBDesigner
- Party member
- Posts: 403
- Joined: Mon Feb 24, 2014 6:54 pm
- Location: Above the Pocket Dimension
- Contact:
Re: Unicode and non-utf8 characters
I'm having issues with the function "utf8unicode". Whenever I use it, it gives me an error: "attempt to call field 'utf8unicode' (a nil value)", even though the function exists and "utf8" is required correctly. Other functions work correctly. If that's an issue of the library with 0.9.x, then I guess this problem cannot be solved, which would suck
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Unicode and non-utf8 characters
I don't see any evidence for that function in the documentation. What are the input and output of that function supposed to be?
Help us help you: attach a .love.
- HugoBDesigner
- Party member
- Posts: 403
- Joined: Mon Feb 24, 2014 6:54 pm
- Location: Above the Pocket Dimension
- Contact:
Re: Unicode and non-utf8 characters
The input would be the argument we get from love.input itself (the non-ASCII character, in this case). The output is supposed to be the unicode of that character, that I'd then index in a list of unicodes and retrieve the corresponding code. In my mod, I associated each non-ASCII character with a code, so that I draw it based on the code, not the character. This way, it is technically just a graphical thing, the texts would have a bunch of code instead of the non-ASCII characters, so it works both in-game and while writing/reading files that contain these characters. I can go into more detail if needed, but as of the function itself, I found it inside the code from [wiki]utf8[/wiki] itself. I have to use the utf8unicode function because, as I said before, using the regular string.byte will return the same number for all non-ASCII characters (198 or something like that).
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Unicode and non-utf8 characters
Okay, so you want to get the decoded codepoint. I still don't completely understand why, you're using a bunch of non-standard terminology.
The function you want to use is utf8.codepoint.
The function you want to use is utf8.codepoint.
Help us help you: attach a .love.
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Google [Bot] and 5 guests