UTF8 characters with HaveItem

Report any Hollywood bugs here
Post Reply
User avatar
jPV
Posts: 604
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

UTF8 characters with HaveItem

Post by jPV »

HaveItem() doesn't find string indices that contain non-english or some special characters if the script is run in the default UTF-8 mode. If you save the file as ASCII and add "@OPTIONS {Encoding = #ENCODING_ISO8859_1}" in the beginning, then it works just fine with the same characters.

I think that if a character is a two-byte UTF-8 character then it doesn't work, but if it's ASCII character then it works even if it'd be a special character like "@" which is represented with a single byte even in UTF-8.

Is this something fixable?

Code: Select all

t = {}

t["ä"] = "test-ä"
DebugPrint(t["ä"])           ; Works
DebugPrint(RawGet(t, "ä"))   ; Works
DebugPrint(HaveItem(t, "ä")) ; Doesn't work

t["®"] = "test-®"
DebugPrint(t["®"])           ; Works
DebugPrint(RawGet(t, "®"))   ; Works
DebugPrint(HaveItem(t, "®")) ; Doesn't work

t["@"] = "test-@"
DebugPrint(t["@"])           ; Works
DebugPrint(RawGet(t, "@"))   ; Works
DebugPrint(HaveItem(t, "@")) ; Works
User avatar
airsoftsoftwair
Posts: 5446
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: UTF8 characters with HaveItem

Post by airsoftsoftwair »

jPV wrote: Thu Nov 02, 2023 8:55 am Is this something fixable?
Sure. Thanks for the MCVE. Will be fixed.
Post Reply