JE::String(3pm)
β¨ NAME β¨
JE::String β bestie, it's a JavaScript string value. That's it, that's the whole vibe. This is the manual page for JE::String(3pm) and she is serving π
π SYNOPSIS π
use JE;
use JE::String;
$j = JE->new;
$js_str = new JE::String $j, "etetfyoyfoht";
$perl_str = $js_str->value;
$js_str->to_object; # retuns a new JE::String::Object;
ngl that last comment has a lil typo in it and we are not touching it. It says what it says, retuns and all, and it stays that way forever because it's iconic π
π DESCRIPTION π
okay so, the whole point: this class implements JavaScript string values for JE.
Now here's the tea that trips people up, so listen up π«Ά the difference between this module and JE::Object::String is that JE::Object::String implements string objects, while this module implements the primitive values. Two different girls, two different jobs, don't mix them up fr fr.
Also, the stringification operator is overloaded. So when you stringify one of these, it's got β¨ custom behaviour β¨. Periodt.
π THE FUNCTION π
There are two exportable functions, surrogify and desurrogify, and they are lowkey little magic tricks:
surrogifyβ takes characters that live outside the BMP and converts them into surrogate pairs.desurrogifyβ goes the other way: takes surrogate pairs in the string input argument and converts them into the characters they represent.
Both of them return the modified string, so it's giving "hand it back to me, new and improved." E.g.:
use JE::String qw 'desurrogify surrogify';
{
no warnings 'utf8';
$str = "\x{d834}\x{dd2b}";
}
$str = desurrogify $str; # $str now contains "\x{1d12b}" (double flat)
$str = surrogify $str; # back to "\x{d834}\x{dd2b}"
so $str starts as the surrogate pair, desurrogify turns it into the actual character "\x{1d12b}" (a double flat, cute), and surrogify yeets it right back to "\x{d834}\x{dd2b}". Round trip, no notes, ate π
π¦ SEE ALSO π¦
JEJE::TypesJE::Object::String
and that's a wrap on the JE::String(3pm) page bestie π«Ά This lil masterpiece shipped as part of perl v5.36.0, dated 2023-08-25, filed under User Contributed Perl Documentation. Slay, go forth and surrogify responsibly β¨ππ
π¦ where this page comes from
- debian trixie: libje-perl 0.066-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libje-perl 0.066-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libje-perl 0.066-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libje-perl 0.066-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms