1

Let me explain my issue with an example:

local Character = utf8.char(1114111) --Example UTF8 character
local A,B,C,D = Character:byte(1, -1)
print(A,B,C,D) -- 244 143 191 191

How can I convert "244 143 191 191" back to "1114111"?

2
  • 1
    utf8.codepoint(string.char(table.unpack{A, B, C, D})) Commented Dec 31, 2018 at 11:46
  • Thank you so much, it works just as I want it! Commented Dec 31, 2018 at 12:29

1 Answer 1

2

The utf8.codepoint function takes a byte array as a string and converts it into a sequence of codepoints, with each return value being a separate codepoint. So you just have to convert those four values into a string for use by utf8.codepoint. string.char(A, B, C, D) would do it adequately.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.