Punycode Converter Library for Python
Project description
punycode
Punycode Converter Library for Python
You can convert Punycode domain to/from Unicode domain with only one function: punycode.convert()
.
How to use
Install
pip install punycode
Function
There is only one function punycode.convert()
.
- input:
input_text: string
Input can be both a Punycode domain and a Unicode domain.
- return:
output_text: string
If you input Punycode domain, the return will be a Unicode domian.
On the other hand, if you input a Unicode domain, you will get a Punycode domain.
Code sample
import punycode
# Convert Unicode domain to Punycode domain
str1 = "美しい.世界"
str2 = "こっち.みんな"
str3 = "日本語.jp"
print(f"{str1} -> {punycode.convert(str1)}")
print(f"{str2} -> {punycode.convert(str2)}")
print(f"{str3} -> {punycode.convert(str3)}")
# 僕だけの.世界 -> xn--08j3a5b142t.xn--rhqv96g
# こっち.みんな -> xn--l8j9flb8a.xn--q9jyb4c
# 日本語.jp -> xn--wgv71a119e.jp
# Punycode domain to Unicode domain
str4 = "xn--n8jub8754b.xn--rhqv96g"
str5 = "xn--28j2af.xn--q9jyb4c"
str6 = "xn--wgv71a119e.jp"
print(f"{str4} -> {punycode.convert(str4)}")
print(f"{str5} -> {punycode.convert(str5)}")
print(f"{str6} -> {punycode.convert(str6)}")
# xn--n8jub8754b.xn--rhqv96g -> 美しい.世界
# xn--28j2af.xn--q9jyb4c -> こっち.みんな
# xn--wgv71a119e.jp -> 日本語.jp
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
punycode-0.1.0.tar.gz
(3.4 kB
view details)
Built Distribution
File details
Details for the file punycode-0.1.0.tar.gz
.
File metadata
- Download URL: punycode-0.1.0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d33190f3696c0e2cb887f6bc13910b3524fb15814876415ec15a2c7236692693 |
|
MD5 | f5f19f5dc6d709f68d764c7a4f94c68f |
|
BLAKE2b-256 | c94c9baeec0b3ade29aee3617cb4b2e9af38f4c4a95a69ad822ff6742a009dc5 |
File details
Details for the file punycode-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: punycode-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54996c9cbaa341b16f60941008c34b5a600ab79a5afa296d84271f3b19d659c5 |
|
MD5 | 5f21bf9b365c4a05e49aefb14e3e0761 |
|
BLAKE2b-256 | 2e8be98acec9df8c6fc8cd57c863cc447c263fd26bee7a200f4d3be3b197ca41 |