[GH-ISSUE #39] Convert unicode letters to punycode #16

Closed
opened 2026-02-27 23:20:02 +03:00 by kerem · 5 comments
Owner

Originally created by @TheAlexLichter on GitHub (Feb 23, 2018).
Original GitHub issue: https://github.com/spatie/dnsrecords.io/issues/39

A few minutes ago I wanted to look up the DNS settings for "ms-umzüge.de", which contains a German umlaut (öäü). Unfortunately, those are stripped out since #9 came through. It'd not suffice to just accept them because dig wouldn't find the Unicode domain. You would also need to convert the domain to Punycode.

(Same would apply to Chinese letters)

Originally created by @TheAlexLichter on GitHub (Feb 23, 2018). Original GitHub issue: https://github.com/spatie/dnsrecords.io/issues/39 A few minutes ago I wanted to look up the DNS settings for "ms-umzüge.de", which contains a German umlaut (öäü). Unfortunately, those are stripped out since #9 came through. It'd not suffice to just accept them because `dig` wouldn't find the Unicode domain. You would also need to convert the domain to Punycode. (Same would apply to Chinese letters)
kerem 2026-02-27 23:20:02 +03:00
Author
Owner

@freekmurze commented on GitHub (Feb 23, 2018):

Feel free to submit a PR to fix this.

<!-- gh-comment-id:368036562 --> @freekmurze commented on GitHub (Feb 23, 2018): Feel free to submit a PR to fix this.
Author
Owner

@crock commented on GitHub (Feb 23, 2018):

I'll try to fix this.

<!-- gh-comment-id:368038268 --> @crock commented on GitHub (Feb 23, 2018): I'll try to fix this.
Author
Owner

@mattiasgeniar commented on GitHub (Feb 23, 2018):

Some pointers having implemented this myself;

Explicit character sets

When calling dig you'll want to explicitly set the Character Set via CHARSET=ASCII. Ie:

CHARSET=ASCII dig +nocmd ... 

This'll require some love in Dns.php.

Conversions

Before & after each DNS lookup, you'll want to throw in some idn_to_ascii() & idn_to_utf8().

Once you tell dig to use the ASCII charset, you feed it only ascii chars. The response will also be ascii, so you have to convert that back to IDN for the human readable version.

<!-- gh-comment-id:368047216 --> @mattiasgeniar commented on GitHub (Feb 23, 2018): Some pointers having [implemented this myself](https://dnsspy.io/); # Explicit character sets When calling `dig` you'll want to explicitly set the Character Set via `CHARSET=ASCII`. Ie: ``` CHARSET=ASCII dig +nocmd ... ``` This'll require some love in [Dns.php](https://github.com/spatie/dns/blob/master/src/Dns.php#L97). # Conversions Before & after each DNS lookup, you'll want to throw in some [idn_to_ascii()](http://php.net/manual/en/function.idn-to-ascii.php) & [idn_to_utf8()](http://php.net/manual/en/function.idn-to-utf8.php). - translate 'täst.de' to 'xn--tst-qla.de': [idn_to_ascii()](http://php.net/manual/en/function.idn-to-ascii.php) - translate 'xn--tst-qla.de' to 'täst.de': [idn_to_utf8()](http://php.net/manual/en/function.idn-to-utf8.php) Once you tell `dig` to use the ASCII charset, you feed it only ascii chars. The response will also be ascii, so you have to convert that back to IDN for the human readable version.
Author
Owner

@crock commented on GitHub (Feb 23, 2018):

I'm a little confused. Is the proposed Conversion changes above supposed to be made in this repo or just in https://github.com/spatie/dns because Dns.php is in the other repo.

<!-- gh-comment-id:368082822 --> @crock commented on GitHub (Feb 23, 2018): I'm a little confused. Is the proposed Conversion changes above supposed to be made in this repo or just in https://github.com/spatie/dns because `Dns.php` is in the other repo.
Author
Owner

@freekmurze commented on GitHub (Feb 23, 2018):

@mattiasgeniar thanks for your wisdom here!

@crock dnsrecords.io uses spatie/dns under the hood. So send your PR to spatie/dns.

<!-- gh-comment-id:368103009 --> @freekmurze commented on GitHub (Feb 23, 2018): @mattiasgeniar thanks for your wisdom here! @crock dnsrecords.io uses spatie/dns under the hood. So send your PR to spatie/dns.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/dnsrecords.io#16
No description provided.