Jump to content

[General] - utf8substr and utf8strlen linux issue


Some1

Recommended Posts

Bug Submission:

Category: General
Issue Title: utf8substr and utf8strlen linux issue
Issue Description: Both functions aren't working as intended on LINUX_STEAM based platforms (not sure about OSX_STEAM).
This causes instant game crash in Text:SetTruncatedString function, when it receives something not-so-english:)
System info:

System Name: Linux
Host Name: iliapc
Release(Kernel) Version: 3.16.0-4-amd64
Kernel Build Timestamp: #1 SMP Debian 3.16.7-ckt20-1+deb8u2 (2016-01-02)
Machine Arch: x86_64
Don't Starve Together: 162028 LINUX_STEAM

Steps to Reproduce: Check this:
print(utf8substr("абвabc",2,5))
print(utf8strlen("абв"))

Yeah, @PeterA, one more weird thing is that utf8substr handles c-like zero-based numbering for the first ("begin") parameter, while using lua-like numbering for the second one ("end").

Would you fix this?

 

Also maybe you should put them into strings table (strings.utf8sub instead of utf8substr, strings.utf8len instead of utf8strlen) and make them more lua-like (to handle default and negative parameters) (here there an example of my own wrapper to utf8substr). What do you think?

And if you check the link I posted above, you may find it good idea to implement other utf8 stuff aswell :-)

  • Developer

We've made a few changes in update 162425:

 

(Previously, utf8substr was actually taking zero-based index and length, not "end".)

 

We've updated utf8substr to match lua's string.sub instead now, so it will take 1-based "begin" and 1-based "end", with support for negative values to count from the end.  It is also hooked up to the string class now, so all of these calls are now valid:

utf8substr(my_string_variable, 1, -2)string.utf8sub(my_string_variable, 1, -2)my_string_variable:utf8sub(1, -2)

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...