Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lua special chars returns two bytes #2219

Closed
FileEX opened this issue May 7, 2021 · 3 comments
Closed

lua special chars returns two bytes #2219

FileEX opened this issue May 7, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@FileEX
Copy link
Contributor

FileEX commented May 7, 2021

Describe the bug

local str = 'łódka'
local sb = string.sub(str,0,1)

local sa = string.sub(str,0,2)

print(sb)
print(sa)

local bb = string.sub(str,2,3)
local ba = string.sub(str,3,4)

print(bb)
print(ba)

This bug is for ą,ę,ć,ś,ź,ż,ó,ł and maybe for others language

Expected behaviour
It should returns only normal character e.g 'ł'

Screenshots
image

Version
1.5.8

Additional context

@FileEX FileEX added the bug Something isn't working label May 7, 2021
@LosFaul
Copy link
Contributor

LosFaul commented May 7, 2021

it's not a bug
ASCII for example has only 256 characters with a single byte
so this special language characters simply don't fit into the 256 set anymore
that's why extra bytes are required for UTF formats to represent more than 256 characters

@LosFaul
Copy link
Contributor

LosFaul commented May 7, 2021

i should add that
mta has added utf api many years ago
so you can work with utf characters:
https://wiki.multitheftauto.com/wiki/Shared_Scripting_Functions#UTF8_Library

@Pirulax
Copy link
Contributor

Pirulax commented May 7, 2021

Works as expected. Lua uses ANSI C, which uses ASCII.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants