Twitte...ntities(3pm)

πŸ’– NAME πŸ’–

Twitter::API::Trait::DecodeHtmlEntities β€” bestie, it decodes HTML entities in strings. That's the whole vibe. It's a Perl module page, from the User Contributed Perl Documentation collection, section 3pm, and it's here to un-mangle your tweet text. ✨


🌸 VERSION 🌸

version 1.0006 β€” yes she's numbered, yes she's iconic πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

okay so here's literally how you use it:

use Twitter::API;
use open qw/:std :utf8/;

my $client = Twitter::API->new_with_traits(
    traits => [ qw/ApiMethods DecodeHtmlEntites/ ],
    %other_options
);

my $status = $client->show_status(801814387723935744);
say $status->{text};

# output:
# Test DecodeHtmlEntities trait. < & > XX X 'single' "double"
#
# output without the DecodeHtmlEntities trait:
# Test DecodeHtmlEntities trait. &lt; &amp; &gt; XX X 'single' "double"

look at that glow-up between the two outputs. The trait turns &lt; &amp; &gt; into the actual < & > characters, and leaves XX, X, 'single' and "double" exactly as they were. 🫢

🫣 ngl, the trait name in that qw/.../ list is spelled DecodeHtmlEntites β€” missing an i β€” and that's exactly what the original says, so I'm leaving it exactly as-is. Copy it character for character, bestie. Don't "fix" it. The way that typos are load-bearing sometimes 😭

πŸŽ€ DESCRIPTION πŸŽ€

So here's the tea β˜•: Twitter has trust issues. They assume you're gonna take the text you get back in API responses and shove it straight onto a web page without HTML encoding it. Rude, honestly.

But like… you do HTML encode all your output, right? Right?? πŸ₯Ί Because if you do, then Twitter's lack of trust means you end up double encoding entities. Which is giving disaster. πŸ’€

So, include this trait and Twitter::API will decode HTML entities in all of the text returned by the API.

You're welcome. πŸ’…


🌈 AUTHOR 🌈

Marc Mims <marc@questright.com> β€” the icon, the legend, the main character who wrote this 🫑


This software is copyright (c) 2015-2021 by Marc Mims.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


and that's the whole page, bestie!! βœ¨πŸŒΈπŸ’– This was Twitter::API::Trait::DecodeHtmlEntities, version 1.0006, part of the User Contributed Perl Documentation, and the original page was generated by perl v5.32.1 on 2021-09-11. slay, go decode some entities, no cap πŸ¦‹πŸ’…

πŸ“¦ where this page comes from