How do I unescape multiple byte character utf8

Ivo Beckers

I want to unescape "Sch%C3%B6ne". I found this unescape function online that works in a lot of cases but not this one because it's 2 characters for one, I tested the following code on http://www.lua.org/cgi-bin/demo

teststring = "Sch%C3%B6ne"

function unescape (str)
        str = string.gsub (str, "+", " ")
        str = string.gsub (str, "%%(%x%x)", function(h) return string.char(tonumber(h,16)) end)
        str = string.gsub (str, "\r\n", "\n")
        return str
end

print(unescape(teststring))

It prints Schöne but I want Schöne. Any one can help me?

Yu Hao

The method works fine, it's the online Lua interpreter that doesn't show correct result in this UTF8 example.

You can test it under another interpreter, e.g, this one.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How encode []rune into []byte using utf8

From Dev

How to convert UTF8 string to byte array?

From Dev

Java how do I convert a byte[] containing multiple doubles into a double[]

From Dev

How to know there is any UTF8 character in a string with Javascript?

From Dev

How do I unescape a unicode escaped string in python?

From Dev

How do I bold multiple instances of a character in an NSString?

From Dev

How do I set URIencoding to UTF8 for Tomcat within AWS Elastic Beanstalk environment?

From Dev

How can I separate byte from character?

From Dev

How do I unescape HTML, then transform it with XSLT?

From Dev

How to use utf8 in multiple choices ModelForm in django?

From Dev

Ruby, Nokogiri: how do i ensure UTF8 throughout nokogiri parsing, erb template, and encoding HTML file

From Dev

How do I get the index of multiple occurrences of the same character in a string?

From Dev

How to convert a UTF8 character to it's corresponding hex value

From Dev

How do I Unescape a String returned from Javascript on Android?

From Dev

how do I print unicode character in C encoded with UTF8?

From Dev

How do I grep for multiple patterns with pattern having a pipe character?

From Dev

How do I replace a multiple sets of characters with a single character

From Dev

How do I get MinTTY working with UTF8

From Dev

UTF8 and T61 strings, how do I see what my SSL cert uses?

From Dev

How to use utf8 in multiple choices ModelForm in django?

From Dev

How to convert a UTF8 character to it's corresponding hex value

From Dev

how to convert decimal to any UTF8 character?

From Dev

How do I convert multiple elements of a character array into an integer?

From Dev

how do I make thunderbird send outgoing mails with utf8 charset?

From Dev

how to use UTF8 character in path Address for Scandir php

From Dev

How do I recover the actual utf8 code from data within MySQL?

From Dev

How does deserialising byte arrays to utf8 know when each character starts/ends?

From Dev

How do I check if a std::string, containing utf8 text, starts with an uppercase letter in Windows?

From Dev

NodeJS function readFileSync - do I pass "utf8" or {encoding: "utf8"}?

Related Related

  1. 1

    How encode []rune into []byte using utf8

  2. 2

    How to convert UTF8 string to byte array?

  3. 3

    Java how do I convert a byte[] containing multiple doubles into a double[]

  4. 4

    How to know there is any UTF8 character in a string with Javascript?

  5. 5

    How do I unescape a unicode escaped string in python?

  6. 6

    How do I bold multiple instances of a character in an NSString?

  7. 7

    How do I set URIencoding to UTF8 for Tomcat within AWS Elastic Beanstalk environment?

  8. 8

    How can I separate byte from character?

  9. 9

    How do I unescape HTML, then transform it with XSLT?

  10. 10

    How to use utf8 in multiple choices ModelForm in django?

  11. 11

    Ruby, Nokogiri: how do i ensure UTF8 throughout nokogiri parsing, erb template, and encoding HTML file

  12. 12

    How do I get the index of multiple occurrences of the same character in a string?

  13. 13

    How to convert a UTF8 character to it's corresponding hex value

  14. 14

    How do I Unescape a String returned from Javascript on Android?

  15. 15

    how do I print unicode character in C encoded with UTF8?

  16. 16

    How do I grep for multiple patterns with pattern having a pipe character?

  17. 17

    How do I replace a multiple sets of characters with a single character

  18. 18

    How do I get MinTTY working with UTF8

  19. 19

    UTF8 and T61 strings, how do I see what my SSL cert uses?

  20. 20

    How to use utf8 in multiple choices ModelForm in django?

  21. 21

    How to convert a UTF8 character to it's corresponding hex value

  22. 22

    how to convert decimal to any UTF8 character?

  23. 23

    How do I convert multiple elements of a character array into an integer?

  24. 24

    how do I make thunderbird send outgoing mails with utf8 charset?

  25. 25

    how to use UTF8 character in path Address for Scandir php

  26. 26

    How do I recover the actual utf8 code from data within MySQL?

  27. 27

    How does deserialising byte arrays to utf8 know when each character starts/ends?

  28. 28

    How do I check if a std::string, containing utf8 text, starts with an uppercase letter in Windows?

  29. 29

    NodeJS function readFileSync - do I pass "utf8" or {encoding: "utf8"}?

HotTag

Archive