Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 950443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:33:55+00:00 2026-05-15T23:33:55+00:00

I want to implement my own tweet compressor . Basically this does the following.

  • 0

I want to implement my own tweet compressor. Basically this does the following. However I’m stuck with some of the unicode issues.

Here’s my script:

#!/usr/bin/env perl
use warnings;
use strict;

print tweet_compress('cc ms ns ps in ls fi fl ffl ffi iv ix vi oy ii xi nj/, "\. " ,", "'),"\n";

sub tweet_compress {
    my $tweet = shift;
    $tweet =~ s/\. ?$//;
    my @orig = ( qw/cc ms ns ps in ls fi fl ffl ffi iv ix vi oy ii xi nj/, ". " ,", ");
    my @new = qw/㏄ ㎳ ㎱ ㎰ ㏌ ʪ fi fl ffl ffi ⅳ ⅸ ⅵ ѹ ⅱ ⅺ nj . ,/;
    $tweet =~ s/$orig[$_]/$new[$_]/g for 0 .. $#orig;
    return $tweet;
}

But this prints junk out at the terminal:

?.?.?.?.?.?.?.f.?.f?.?.?.?.?.?.?.nj/."\..,"."

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:33:55+00:00Added an answer on May 15, 2026 at 11:33 pm

    Two issues.

    Firstly you have unicode characters in your source code. Make sure you save your file as utf8 and use the use utf8 pragma.

    Also if you intend to run this program from a console make sure it can handle unicode. Windows command prompt cannot and will always show ? regardless of whether your data is correct or not. I ran this on Mac OS with Terminal set to handle utf8.

    Secondly, if you have “.” in your orig list, it’ll get interpreted as “any single character” and give you wrong results – so you need to escape it before using it in your regular expression. I’ve modified the program a little to make it work.

    #!/usr/bin/env perl
    use warnings;
    use strict;
    use utf8; #use character semantics
    
    #make sure the data is re-encoded to utf8 when output to terminal
    binmode STDOUT, ':utf8';
    
    print tweet_compress('cc ms ns ps in ls fi fl ffl ffi iv ix vi oy ii xi nj/, "\. " ,", "'),"\n";
    
    sub tweet_compress {
        my $tweet = shift;
        $tweet =~ s/\. ?$//;
        my @orig = ( qw/cc ms ns ps in ls fi fl ffl ffi iv ix vi oy ii xi nj/, '\. ' ,", ");
        my @new = qw/㏄ ㎳ ㎱ ㎰ ㏌ ʪ fi fl ffl ffi ⅳ ⅸ ⅵ ѹ ⅱ ⅺ nj . ,/;
        $tweet =~ s/$orig[$_]/$new[$_]/g for 0 .. $#orig;
        return $tweet;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to modify this method (implement my own version of it) but I
I want to implement my own clustering algorithm using this Virtual Earth javascript API:
So, I want to implement my own binary serialization. I'm looking for some examples
I want to implement my own copy method for a class A which looks
I want to implement all my own rotation animations but if I only return
I want to implement an action bar for my own android app like the
I'm developing own CMS and i want to implement functionality to dynamically include existing
In Django admin I want to override and implement my own form for a
I'm attempting to override and implement my own TabExpansion. In the function I want
i starter in jqgrid, i want implement inline edit in jqgrid i have this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.