Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Open Source > Perl
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Perl section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 15th, 2009, 01:39 AM
Authorized User
Points: 181, Level: 3
Points: 181, Level: 3 Points: 181, Level: 3 Points: 181, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2009
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to find the non-ascii character using perl

Dear all,

Pls. tell me how to find the non-english character by regular expression like
$line =~ m/[regular expression] /g;


example:
values of these surfactant–cobalt



Thanks,
Thava
Reply With Quote
  #2 (permalink)  
Old April 21st, 2009, 11:44 AM
Friend of Wrox
Points: 1,515, Level: 15
Points: 1,515, Level: 15 Points: 1,515, Level: 15 Points: 1,515, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2003
Location: Oxford, , United Kingdom.
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Code:
#!/usr/bin/perl
use warnings;
use strict;

while(<>) {
  tr/\000-\177//cd; 
  print;
}
__________________
--
Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk
Reply With Quote
  #3 (permalink)  
Old August 11th, 2011, 06:22 AM
Registered User
Points: 37, Level: 1
Points: 37, Level: 1 Points: 37, Level: 1 Points: 37, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2011
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Hi,

How to replace the non-asciii value into the XML number entities.

eg:

values of these surfactant–cobalt

output:

values of these surfactant &#x????; cobalt
Reply With Quote
  #4 (permalink)  
Old November 13th, 2011, 09:24 PM
Friend of Wrox
Points: 1,515, Level: 15
Points: 1,515, Level: 15 Points: 1,515, Level: 15 Points: 1,515, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2003
Location: Oxford, , United Kingdom.
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Would HTML::Entities work for you? If not something like:

Code:
#!/usr/bin/perl
use warnings;
use strict;
use utf8;
use 5.10.1;


binmode STDOUT, 'utf8'; # needed on some terminals where you don't defsault to utf8
my $unicode_string="vis-à-vis Beyoncé's naïve\npapier-mâché résumé";
say "Start: $unicode_string";
$unicode_string =~s/([^[:ascii:]])/'&#' . ord($1) . ';'/ge;
say "End: $unicode_string";
__________________
--
Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get Ascii code for a character in XSLT mswin XSLT 8 November 28th, 2008 07:21 AM
ascii umeshtheone Beginning VB 6 2 June 12th, 2007 03:56 AM
find character % and format column paul20091968 Excel VBA 0 January 29th, 2007 04:45 AM
Get UNICODE or ASCII Value of a character Eyob_the_pro C# 0 January 10th, 2007 02:42 AM
Converting an ASCII character to binary? skyraider Visual Basic 2005 Basics 0 May 7th, 2006 08:20 PM



All times are GMT -4. The time now is 05:09 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.