Skip to main content.
home | support | download

Back to List Archive

Re: Detecting multibyte/wide characters?

From: J Robinson <jrobinson852(at)not-real.yahoo.com>
Date: Mon Oct 04 2004 - 21:25:20 GMT
Thanks for the useful responses, Bill and friedfish!
jrobinson

--- Bill Schell <friedfish@optonline.net> wrote:

> We prefer to be called swisheans. :-)
> 
> This function should do what you want, assuming you
> want
> to know if you have any multibyte characters in a
> string.
> 
> use bytes();
> 
> sub string_has_multibyte_chars {
>     my ($string) = @_;
>     return 1 if (length($string)  <
> bytes::length(string));
>     return 0;
> }
> 
> Note that you must have the 'use' line exactly that
> way.
> If you just say 'use bytes', the all of your calls
> to length
> will be to bytes::length in the current lexical
> scope.
> 
> 
> J Robinson wrote:
> 
> >Hello swisheites:
> >
> >I have a question related to swish-e, if someone in
> >this knowledgable group might know the answer:
> >
> >Suppose I have word in a perl scalar ($w). 
> >
> >How can I detect if $w contains multibyte or 'wide'
> >characters?  
> >
> >Thanks in advance if anyone knows. I suppose this
> >might be in a faq somewhere but I couldn't find it.
> >Thanks again.
> >jrobinson
> >


		
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
Received on Mon Oct 4 14:25:53 2004