Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

string matching with extented ASCII characters

by Anonymous Monk
on Jun 11, 2003 at 08:35 UTC ( [id://264980]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Perl Monks, I know that you do not like lazy person and use expertise for simple stuff. Since I am a newbie and try to accomplish a task that is quite advance, if you do not mind, I would like get a help from you again. I am trying to read a bardcode from a serail port. However I am getting nonprinting extented ascii character and try to replace them with meaningful one eg. "500039„§03363„§" replace "„§" with "4". As you can imagine I could not figure it out. I am using a below command to do it, but it cannot recognize "„§" that is Chr 180. $Buffer =~ s/(char 180)/4/eg ; Regards,
  • Comment on string matching with extented ASCII characters

Replies are listed 'Best First'.
Re: string matching with extented ASCII characters
by zakb (Pilgrim) on Jun 11, 2003 at 08:40 UTC

    Well, if that "„§" really is chr(180), then you can find it like this:

    $Buffer =~ s/\xb4/4/g;

    \x takes a hex code. See perlretut or perlre.

      thanks zakb, actually the char(180) was not printed write in the message but \xb4 simply solved the issue. Thanks again.
Re: string matching with extented ASCII characters
by CountZero (Bishop) on Jun 11, 2003 at 09:43 UTC

    Just being curious, why would s/,,§/4/g not work?

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      Because ,,§ is not chr(180).

      Update: see here.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://264980]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-23 17:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found