develooper Front page | perl.perl5.porters | Postings from January 2010

Re: warding against bytes.pm

Thread Previous | Thread Next
From:
John
Date:
January 5, 2010 10:56
Subject:
Re: warding against bytes.pm
Message ID:
4B438B6A.4000705@vodafoneemail.co.uk
Zefram wrote:
> Dr.Ruud wrote:
>   
>> A byte count can be very useful,
>> for example if you need to stay
>> within MySQL's max_allowed_packet
>> when creating big SQL statements.
>>     
>
> For that purpose, what you need to know is the number of bytes that
> you'll be sending to MySQL.  This depends on the characters and how
> you're encoding them for communication with MySQL, *not* on how Perl
> is representing them internally.  See previous messages about writing
> UTF-8-encoded text to a file.
>
> -zefram
>
>   

I think the problem here is that we think of  characters in Perl being 
in UTF-8. We need to get away from this  idea and think of characters as 
*CHARACTERS* they only become bytes when encoded into some other format 
for transport out of the program.

So if you want to send UTF-8 to MySQL you need to take you string and 
encode it to UTF-8 only then can you get a length of bytes from it.

John

PS This means we need to remove any talk of UTF-8 encoding for Perl 
characters from all documentation except the Perl Guts docs.


______________________________________________        
This email has been scanned by Netintelligence        
http://www.netintelligence.com/email


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About