Re: pgsql and exception [message #178137 is a reply to message #178118] |
Mon, 14 May 2012 20:33 |
M. Strobel
Messages: 386 Registered: December 2011
Karma:
|
Senior Member |
|
|
Am 14.05.2012 15:26, schrieb Une Bévue:
> On 14/05/12 14:56, M. Strobel wrote:
>> how about substr()?
> right I'm testing that however I'm not sure it works with accentuated (UTF-8)
> characters.
>
> for example with :
> --- code ---------------------------------------------------------------
> <?php
> header('Content-Type:text/html; charset=utf-8');
>
> $str="Etre ou ne pas etre, telle est est la question.";
> echo $str."<br />";
> echo strlen($str)."<br />";
> echo substr($str, 0, 16)."<br />";
>
> $str="Être ou ne pas être, telle est est la question."; // Accentuated
> echo $str."<br />";
> echo strlen($str)."<br />";
> echo substr($str, 0, 16)."<br />";
>
> ?>
> ------------------------------------------------------------------------
>
> I get :
> Etre ou ne pas etre, telle est est la question.
> 47
> Etre ou ne pas e
> Être ou ne pas être, telle est est la question.
> 49
> Être ou ne pas
>
Je programme donc je suis.
You get the string length in bytes, which is okay when you want to store it in a
length limited field. If you want the length for display formatting this is a problem.
Good programming languages now make a difference between string length in bytes and
string length in characters.
Did not find this one in PHP.
/Str.
|
|
|