Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #12501 > unrolled thread

Processing accented characters submitted from forms

Started byJohnT <john-sospam@jtresponse.co.uk>
First post2014-01-02 15:55 +0000
Last post2014-01-03 17:08 +0100
Articles 2 on this page of 22 — 7 participants

Back to article view | Back to comp.lang.php


Contents

  Processing accented characters submitted from forms JohnT <john-sospam@jtresponse.co.uk> - 2014-01-02 15:55 +0000
    Re: Processing accented characters submitted from forms "J.O. Aho" <user@example.net> - 2014-01-02 18:15 +0100
      Re: Processing accented characters submitted from forms JohnT <john-sospam@jtresponse.co.uk> - 2014-01-03 11:37 +0000
        Re: Processing accented characters submitted from forms Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-01-03 12:37 +0000
          Re: Processing accented characters submitted from forms Tim Streater <timstreater@greenbee.net> - 2014-01-03 12:52 +0000
            Re: Processing accented characters submitted from forms JohnT <john-sospam@jtresponse.co.uk> - 2014-01-03 13:00 +0000
              Re: Processing accented characters submitted from forms Jerry Stuckle <jstucklex@attglobal.net> - 2014-01-03 10:09 -0500
              Re: Processing accented characters submitted from forms "J.O. Aho" <user@example.net> - 2014-01-03 18:57 +0100
          Re: Processing accented characters submitted from forms JohnT <john-sospam@jtresponse.co.uk> - 2014-01-03 12:53 +0000
            Re: Processing accented characters submitted from forms Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-01-03 14:30 +0000
              Re: Processing accented characters submitted from forms Jerry Stuckle <jstucklex@attglobal.net> - 2014-01-03 10:11 -0500
                Re: Processing accented characters submitted from forms Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-01-03 20:28 +0000
                  Re: Processing accented characters submitted from forms Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-01-03 22:54 +0100
                  Re: Processing accented characters submitted from forms Tim Streater <timstreater@greenbee.net> - 2014-01-03 21:58 +0000
                  Re: Processing accented characters submitted from forms Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-01-03 22:01 +0000
                  Re: Processing accented characters submitted from forms Jerry Stuckle <jstucklex@attglobal.net> - 2014-01-03 19:59 -0500
    Re: Processing accented characters submitted from forms Christoph Michael Becker <cmbecker69@arcor.de> - 2014-01-02 20:52 +0100
      Re: Processing accented characters submitted from forms JohnT <john-sospam@jtresponse.co.uk> - 2014-01-03 11:40 +0000
        Re: Processing accented characters submitted from forms Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-01-03 13:53 +0100
          Re: Processing accented characters submitted from forms JohnT <john-sospam@jtresponse.co.uk> - 2014-01-03 13:05 +0000
            Re: Processing accented characters submitted from forms Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-01-03 16:03 +0100
              Re: Processing accented characters submitted from forms Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-01-03 17:08 +0100

Page 2 of 2 — ← Prev page 1 [2]


#12528

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-01-03 16:03 +0100
Message-ID<2759689.Qh6PuGQvD6@PointedEars.de>
In reply to#12524
JohnT wrote:
^^^^^
Please fix.

> On Fri, 03 Jan 2014 13:53:04 +0100, Thomas 'PointedEars' Lahn wrote:
>> JohnT wrote:
>>> Changing to UTF-8 is not an option,
>> Why not?
> 
> It's a big site.
> It would take too much work to rebuild it all.

Looks like an inherent design flaw to me.  It is rather easy to switch a 
properly developed site to UTF-8.  BTDT.
 
>>> as that is the PHP 5 default,
>> 
>> How did you get this idea?
> 
> http://uk1.php.net/manual/en/function.htmlentities.php
> 
> says:
>     Like htmlspecialchars(), htmlentities() takes an optional third
> argument encoding which defines encoding used in conversion. If omitted,
> the default value for this argument is ISO-8859-1 in versions of PHP
> prior to 5.4.0, and UTF-8 from PHP 5.4.0 onwards.
> 
>>> and makes the programming a lot easier.
>> If only it were so.  PHP 5 still is oblivious as to character encoding.
> 
> http://uk1.php.net/manual/en/book.iconv.php

That is interesting (I did not know about the new htmlentities() default), 
but it does not refute my argument.  First, there have been versions of 
PHP 5 *before* 5.4.0.  Second, so far you have to *tell* PHP 5 what encoding 
you use; there is no automatism or assumed default encoding for source code 
(as in some other recent programming languages) – *only* in the PHP 5.*4* 
case *with* htmlentities() the default suffices.  (Such an automatism is 
considered for PHP *6*.)

That said, htmlentities() is insufficient to represent arbitrary Unicode 
characters, encoded with UTF-8 server-side, in an HTML document if the 
document encoding is not UTF-8; you would have to use htmlspecialchars() 
which has the same default parameter value since PHP 5.4.0.

<http://php.net/htmlspecialchars>


PointedEars
-- 
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
  -- Richard Cornford, cljs, <cife6q$253$1$8300dec7@news.demon.co.uk> (2004)

[toc] | [prev] | [next] | [standalone]


#12531

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-01-03 17:08 +0100
Message-ID<9721308.9kJrD6T3nN@PointedEars.de>
In reply to#12528
Thomas 'Ingrid' Lahn wrote:

> JohnT wrote:
>> On Fri, 03 Jan 2014 13:53:04 +0100, Thomas 'PointedEars' Lahn wrote:
>>> JohnT wrote:
>>>> [UTF-8] is the PHP 5 default,
>>> 
>>> How did you get this idea?
>> 
>> http://uk1.php.net/manual/en/function.htmlentities.php
>> 
>> says:
>>     Like htmlspecialchars(), htmlentities() takes an optional third
>> argument encoding which defines encoding used in conversion. If omitted,
>> the default value for this argument is ISO-8859-1 in versions of PHP
>> prior to 5.4.0, and UTF-8 from PHP 5.4.0 onwards.
>
> […]
> That said, htmlentities() is insufficient to represent arbitrary Unicode
> characters, encoded with UTF-8 server-side, in an HTML document if the
> document encoding is not UTF-8; you would have to use htmlspecialchars()
> which has the same default parameter value since PHP 5.4.0.
> 
> <http://php.net/htmlspecialchars>

Actually, it is worse.  In such a document, to refer to even those Unicode 
characters for which there is *not* a character entity reference in HTML, 
you have to use mb_encode_numericentity():

$ php -r 'echo mb_encode_numericentity("∎", array(0x0, 0x10000, 0, 0xfffff), 
"UTF-8") . PHP_EOL;'
&#8718;

$ locale
LANG=de_CH.UTF-8
LANGUAGE=
LC_CTYPE="de_CH.UTF-8"
LC_NUMERIC="de_CH.UTF-8"
LC_TIME="de_CH.UTF-8"
LC_COLLATE="de_CH.UTF-8"
LC_MONETARY="de_CH.UTF-8"
LC_MESSAGES=en_US.UTF-8
LC_PAPER="de_CH.UTF-8"
LC_NAME="de_CH.UTF-8"
LC_ADDRESS="de_CH.UTF-8"
LC_TELEPHONE="de_CH.UTF-8"
LC_MEASUREMENT="de_CH.UTF-8"
LC_IDENTIFICATION="de_CH.UTF-8"
LC_ALL=

----------

<http://php.net/mb_encode_numericentity>

None of this is necessary if you use UTF-8 throughout.


PointedEars
-- 
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
  -- Richard Cornford, cljs, <cife6q$253$1$8300dec7@news.demon.co.uk> (2004)

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.php


csiph-web