Solved

How to check if a string is UTF-8 encoded in perl

Posted on 2011-09-26
2
523 Views
Last Modified: 2012-05-12
How to check if a string is UTF-8 encoded in perl ?

I have used Test::utf8 ie is_sane_utf8($string) though i am getting what i want, but it is printing some unnecessary text in the output. Please help

~manu

0
Comment
Question by:manugeek
2 Comments
 
LVL 9

Accepted Solution

by:
parparov earned 500 total points
ID: 36602282
Consider
use utf8;
is_utf8($string);
is_valid_utf8($string);

Open in new window

http://perldoc.perl.org/utf8.html
Test::utf8 is an old framework.
0
 

Author Closing Comment

by:manugeek
ID: 36706973
Thanks

~Manu
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Perl for loop for 2000 ms 7 91
perl CPAN issue 3 90
pipe to sed or perl, please help 5 120
Perl Awk Need Help 3 94
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now