I need to convert the punycode NIATO-OTABD to nñiñatoñ.
I found a text converter in JavaScript the other day, but the punycode conversion doesn’t work if there’s a dash in the middle.
Any suggestion to fix the ‘dash’ issue?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I took the time to create the punycode below. It it based on the C code in RFC 3492. To use it with domain names you have to remove/add
xn--from/to the input/output to/from decode/encode.The
utf16-classis necessary to convert from JavaScripts internal character representation to unicode and back.There are also
ToASCIIandToUnicodefunctions to make it easier to convert between puny-coded IDN and ASCII.Licence:
From RFC3492:
I put my work in this punycode and utf16 in the public domain. It would be nice to get an email telling me in what project you use it.
The scope of the code
Each TLD has rules for which code points are allowed. The scope of the code below is to encode and decode a string between punycode and the internal encoding used by javascript regardes of those rules. Depending on your use case, you may need to filter the string. For example, 0xFE0F: Variation Selector-16, an invisible code point that specifies that the previous character should be displayed with emoji presentation. If you search for "allowed code points in IDN" you should find several projects that can help you filter the string.