TIMTOWTDI but here's an illustrative test. See also How to ask better questions using Test::More and sample data
use strict; use warnings; use Encode 'encode'; use Unicode::Char; use Test::More tests => 2; is to_bytes ('0x03C0'), 'CF80', 'Code point to bytes (0x format)'; is to_bytes ('U+03C0'), 'CF80', 'Code point to bytes (U+ format)'; sub to_bytes { my $u = Unicode::Char->new; (my $in = shift) =~ s/^(?:0x|U\+)//; return uc unpack 'H*', encode 'UTF-8', $u->u ($in); }
Translating bytes to code points is left as an exercise.
🦛
In reply to Re: How to convert between Unicode codepoint and UTF8 character code on Perl?
by hippo
in thread How to convert between Unicode codepoint and UTF8 character code on Perl?
by wyt248er
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |