LoTROInterface

LoTROInterface (https://www.lotrointerface.com/forums/index.php)
-   Lua Programming Help (L) (https://www.lotrointerface.com/forums/forumdisplay.php?f=50)
-   -   Special Character Problem (https://www.lotrointerface.com/forums/showthread.php?t=2400)

Gimp 12-27-2013 08:12 PM

Special Character Problem
 
I'm having a problem with special characters that maybe someone can help me with.

I'm hard coding a string in a table and trying to compare it to other strings I get from chat text. The problem I run into is when the string has special characters.

For instance, I have "Tham Mírdain" as one of my hard coded strings. If I print it to screen, it comes out as "Tham M?rdain". However, when I catch "Tham Mírdain" in my chat text, place it in a variable and print it to screen, it prints correctly. Comparing Tham M?rdain to Tham Mírdain isn't going to work.

Any ideas on why it is doing this and how to fix it?

Garan 12-27-2013 08:29 PM

How are you hard coding the string? If you are simply typing "Tham Mírdain" into a text file and saving it, you may find that it will not be parsed by the Lua interpreter correctly. Some have had luck saving their source files with UTF-8 encoding. I prefer to force the string to it's expected value using the escaped byte values that make up the UTF character. In the case of "Tham Mírdain" it would be represented as "Tham M\195\173rdain" where the bytes 195 and 173 represent the "í" character. There is also a .lua file that defines the special characters available at http://www.lotrointerface.com/downlo...ingHelper.html if you prefer to go that way. As to comparing strings, I wrote a fairly simple mapping to strip special accents so that strings can be compared without the special characters so that users don't have to worry about entering the correct accents when searching for locations - check out the string.stripaccent function in MoorMap's main.lua file if you are interested.

Gimp 12-30-2013 08:20 PM

I tried encoding it in UTF8 but lotro gave me errors when I tried loading the file. I went with using the UTF helper by Ooz, which seems to work for me.

Thanks for telling me about it. I searched the forums, but I wasn't using the right search terms it seems :)

Thurallor 12-30-2013 10:33 PM

I use Notepad++ and save the file in "UTF without BOM" encoding. Works for me.


All times are GMT -5. The time now is 04:28 PM.

vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI