Re: comparing binary strings
- From: Joost Diepenmaat <joost@xxxxxxxxx>
- Date: 10 Dec 2007 16:34:00 GMT
On Mon, 10 Dec 2007 14:27:12 +0000, Ben Morrow wrote:
Quoth Yakov <iler.ml@xxxxxxxxx>:
, and I need to ensure that comparison (lt, gt) of those strings not
depend on locale and not be utf-8 interpreted.
Don't use locales then. For the purposes of lt and gt and eq it's
irrelevant wether the strings are utf-8 encoded or not.
If you want to be able to output them as bytes, just don't insert any
chars > 255.
Don't attempt to mix POSIX locales and Perl's UTF8 support. The two
don't play well together at all yet.
Yup.
How can I "label" thise string "raw binary" in CreateEightByteString
so that any subsequent comparison be as raw binary 8 bytes, independent
on program's locale ?
You can't. You need to perform *the comparisons* under 'use bytes'.
No, you don't need to. The only time the encoding of the strings is
important is when you're passing them to external code as a C-style char*
pointer. Or at least it should be.
In general, I'd say: don't use bytes. It breaks stuff - for instance, it
makes it impossible to compare an utf-8 encoded string with a non-utf8
encoded one.
If you aren't using locales, and you call CreateEightByteString under
'use bytes', you will get byte-strings back. If you only mix these with
other byte-strings, they will stay that way.
As long as you're reading and writing to filehandles that have the
correct encoding layer the internal encoding of the strings doesn't
matter to perl code.
Joost.
.
- Follow-Ups:
- Re: comparing binary strings
- From: Ben Morrow
- Re: comparing binary strings
- References:
- comparing binary strings
- From: Yakov
- Re: comparing binary strings
- From: Ben Morrow
- comparing binary strings
- Prev by Date: Re: Problem in LDAP authentication
- Next by Date: Re: Problem in LDAP authentication
- Previous by thread: Re: comparing binary strings
- Next by thread: Re: comparing binary strings
- Index(es):
Relevant Pages
|