Unicode::Escape(3pm)

πŸ“¦
version 0.0.2 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble

πŸ’– Unicode::Escape πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation set β€” it's the manual for Unicode::Escape, a Perl module that lives at section 3pm. And literally all it does is take your non-ASCII Unicode characters and turn them into escape sequences, or turn them back. That's it. That's the whole vibe. πŸ¦‹


✨ NAME ✨

Unicode::Escape β€” escape and unescape Unicode characters other than ASCII, no cap. πŸ”₯


🌸 VERSION 🌸

This document describes Unicode::Escape version 0.0.1. She's an old soul, we stan. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

so here's the whole thing in action. Escape Unicode charactors like '\u3042\u3043\u3044'. JSON thinks No more Garble!! (that's the module's own words and I'm not changing a single letter of it 🫢)

# Escape Unicode charactors like '\u3042\u3043\u3044'.
# JSON thinks No more Garble!!

# case 1
use Unicode::Escape;
my $escaped1 = Unicode::Escape::escape($str1, 'euc-jp');             # $str1 contains charactor that is not ASCII. $str1 is encoded by euc-jp.
my $escaped2 = Unicode::Escape::escape($str2);     # default is utf8 # $str2 contains charactor that is not ASCII.
my $unescaped1 = Unicode::Escape::unescape($str3, 'shiftjis');       # $str3 contains escaped Unicode character. return value is encoded by shiftjis.
my $unescaped2 = Unicode::Escape::unescape($str4); # default is utf8 # $str4 contains escaped Unicode character.

# case 2
use Unicode::Escape qw(escape unescape);
my $escaped1 = escape($str1, 'euc-jp');             # $str1 contains charactor that is not ASCII. $str1 is encoded by euc-jp.
my $escaped2 = escape($str2);     # default is utf8 # $str2 contains charactor that is not ASCII.
my $unescaped1 = unescape($str3, 'shiftjis');       # $str3 contains escaped Unicode character. return value is encoded by shiftjis.
my $unescaped2 = unescape($str4); # default is utf8 # $str4 contains escaped Unicode character.

# case 3
use Unicode::Escape;
my $escaper = Unicode::Escape->new($str, 'shiftjis'); # $str contains charactor that is not ASCII. $str is encoded by shiftjis.(default is utf8)
my $escaped = $escaper->escape;

# case 4
use Unicode::Escape;
my $escaper = Unicode::Escape->new($str); # $str contains escaped Unicode character.
my $unescaped1 = $escaper->unescape('shiftjis');
my $unescaped2 = $escaper->unescape;      # default is utf8.

four whole cases, bestie. function-style, import-style, object-style, and object-style-but-unescaping. pick your fighter. πŸ‘‘


🌈 DESCRIPTION 🌈

Escape and unescape Unicode characters other than ASCII. That's the whole job description. And the iconic part? When the server response is javascript code, it is convenient. β€” like, that's the origin story right there. your server's sending back JS, the characters are getting garbled, and this module just fixes it. main character energy fr fr. 😭


πŸ’œ METHODS πŸ’œ

🧚 new( $string[, $encode ] )

  • string β€” the target string for escape or unescape. this is the thing you're working on. πŸ“
  • encode β€” for instance, 'utf8', 'shiftjis', and 'euc-jp', etc. (See Encode)

⭐ escape( $string[, $encode ] )

  • string β€” the target string. This argument is unnecessary when called as object method. so if you went the ->new route, you already handed her the string, don't double up. πŸ™ˆ
  • encode β€” for instance, 'utf8', 'shiftjis', and 'euc-jp', etc. (See Encode) This argument is unnecessary when called as object method.

πŸ¦‹ unescape( $string[, $encode ] )

  • string β€” the target string. This argument is unnecessary when called as object method.
  • encode β€” for instance, 'utf8', 'shiftjis', and 'euc-jp', etc. (See Encode)
heads up: the encode list here is literally 'utf8', 'shiftjis', 'euc-jp', etc. β€” and it points you at Encode for the full tea. go read that one, she's thorough. πŸ’–

πŸ‘€ SEE ALSO πŸ‘€

  • Unicode::String
  • Encode

πŸ’€ INCOMPATIBILITIES πŸ’€

None reported. clean sheet, glowing skin, no drama. ✨


😭 BUGS AND LIMITATIONS 😭

No bugs have been reported.

Please report any bugs or feature requests to "bug-unicode-escape@rt.cpan.org", or through the web interface at <http://rt.cpan.org>.

bestie if you find a bug, do NOT just sit there silently suffering. email her. she wants to know. 🫢

πŸ‘‘ AUTHOR πŸ‘‘

Hitoshi Amano "<seijro@gmail.com>"


Copyright (c) 2006, Hitoshi Amano "<seijro@gmail.com>". All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.


πŸ”₯ DISCLAIMER OF WARRANTY πŸ”₯

okay so this part is in ALL CAPS in the original and it's giving very serious legal energy, so I'm keeping every word of it exactly as dramatic as it is:

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

translation bestie: it's free, so if it breaks, that's on you. no cap. πŸ’…

and that's the whole page!! πŸŽ€ this one came to you courtesy of perl v5.34.0, dated 2022-06-28, living in the Unicode::Escape(3pm) slot of your friendly neighbourhood perl docs. go escape some characters, you absolute icon. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from