Re: [PHP] Re: require() causing strange characters ?

2009-02-10 Thread Nisse Engström
On Mon, 9 Feb 2009 15:46:35 +0100, cr.vege...@gmail.com wrote:

 I've tested it again, from scratch with Notepad editor:
 
 echoUTF8.php?php require(echoUTF8sub.php); ?
 echoUTF8sub.php   ?php echo test; ?
 and keep getting strange characters.
 
 Would you be so kind to run these 2 scripts on your pc ?

Works fine for me, probably because my copy of Notepad
is so old it has never heard of Unicode...

Here's another test:

echoUTF8.php:
-
?php require 'echoUTF8sub.php';

echoUTF8sub.php:

?php echo \xef\xbb\xbf, test\n;  // Manual BOM

When I run this from a browser, I get different output
depend on the server's and browser's default charset,
and PHP's default_charset setting.

I get consistent results when I add

  header ('Content-Type: text/plain; charset=utf-8');

to echoUTF8.php.


(When the scripts are run from command-line, the output
 would also depend on the shells ability to handle utf-8.)


/Nisse

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: require() causing strange characters ?

2009-02-10 Thread Ashley Sheridan
On Tue, 2009-02-10 at 12:36 +0100, Nisse Engström wrote:
 On Mon, 9 Feb 2009 15:46:35 +0100, cr.vege...@gmail.com wrote:
 
  I've tested it again, from scratch with Notepad editor:
  
  echoUTF8.php?php require(echoUTF8sub.php); ?
  echoUTF8sub.php   ?php echo test; ?
  and keep getting strange characters.
  
  Would you be so kind to run these 2 scripts on your pc ?
 
 Works fine for me, probably because my copy of Notepad
 is so old it has never heard of Unicode...
 
 Here's another test:
 
 echoUTF8.php:
 -
 ?php require 'echoUTF8sub.php';
 
 echoUTF8sub.php:
 
 ?php echo \xef\xbb\xbf, test\n;  // Manual BOM
 
 When I run this from a browser, I get different output
 depend on the server's and browser's default charset,
 and PHP's default_charset setting.
 
 I get consistent results when I add
 
   header ('Content-Type: text/plain; charset=utf-8');
 
 to echoUTF8.php.
 
 
 (When the scripts are run from command-line, the output
  would also depend on the shells ability to handle utf-8.)
 
 
 /Nisse
 
I know this might be going slightly off topic, but just wanted to
suggest Notepad++ as an alternative text editor. I use it when I work on
Windows systems, and it's been a great boon, adding some of those nice
features as well as supporting utf-8, etc.


Ash
www.ashleysheridan.co.uk


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: require() causing strange characters ?

2009-02-09 Thread cr.vegelin

Thanks Nisse,

- Original Message - 
From: Nisse Engström news.nospam.0ixbt...@luden.se

To: php-general@lists.php.net
Sent: Sunday, February 08, 2009 6:06 PM
Subject: Re: [PHP] Re: require() causing strange characters ?



On Fri, 6 Feb 2009 10:11:49 +0100, cr.vege...@gmail.com wrote:


I saved both scripts with ANSI in stead of UTF-8 and the problem is gone.
So the utf-8 BOM character (Byte Order Mark) caused it.
Unfortunately my editor has no option to store BOM-free scripts.

Is it standard that PHP scripts should be saved without a BOM character ?


This is not a PHP matter, unless PHP 6 (which will have
Unicode support) does something with it. PHP 5 just outputs
it as is.

A BOM character is supposed to be the *first* character in
a text stream. Otherwise it should be treated as a
ZERO WIDTH NON-BREAKING SPACE.

http://unicode.org/faq/utf_bom.html#bom1


Test results ...
If test.php (utf8) requires echo.php (utf8), page source has 
C�testD,

size 9
If test.php (ansi) requires echo.php (utf8), page source has
CtestD, size 7
If test.php (ansi) requires echo.php (ansi), page source has 
CtestD,

size 6

The reason for asking is that sometimes  is displayed on some pages.


That means you've used a utf-8 BOM in a page using an 8-bit
character encoding (eg. iso-8859-1 or similar), or that you
have utf-8 encoded it twice.
/Nisse


I've tested it again, from scratch with Notepad editor:

echoUTF8.php?php require(echoUTF8sub.php); ?
echoUTF8sub.php   ?php echo test; ?
and keep getting strange characters.

Would you be so kind to run these 2 scripts on your pc ?

TIA, Cor



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: require() causing strange characters ?

2009-02-09 Thread Ashley Sheridan
On Mon, 2009-02-09 at 15:46 +0100, cr.vege...@gmail.com wrote:
 Thanks Nisse,
 
 - Original Message - 
 From: Nisse Engström news.nospam.0ixbt...@luden.se
 To: php-general@lists.php.net
 Sent: Sunday, February 08, 2009 6:06 PM
 Subject: Re: [PHP] Re: require() causing strange characters ?
 
 
  On Fri, 6 Feb 2009 10:11:49 +0100, cr.vege...@gmail.com wrote:
 
  I saved both scripts with ANSI in stead of UTF-8 and the problem is gone.
  So the utf-8 BOM character (Byte Order Mark) caused it.
  Unfortunately my editor has no option to store BOM-free scripts.
 
  Is it standard that PHP scripts should be saved without a BOM character ?
 
  This is not a PHP matter, unless PHP 6 (which will have
  Unicode support) does something with it. PHP 5 just outputs
  it as is.
 
  A BOM character is supposed to be the *first* character in
  a text stream. Otherwise it should be treated as a
  ZERO WIDTH NON-BREAKING SPACE.
 
  http://unicode.org/faq/utf_bom.html#bom1
 
  Test results ...
  If test.php (utf8) requires echo.php (utf8), page source has 
  C�testD,
  size 9
  If test.php (ansi) requires echo.php (utf8), page source has
  CtestD, size 7
  If test.php (ansi) requires echo.php (ansi), page source has 
  CtestD,
  size 6
 
  The reason for asking is that sometimes  is displayed on some pages.
 
  That means you've used a utf-8 BOM in a page using an 8-bit
  character encoding (eg. iso-8859-1 or similar), or that you
  have utf-8 encoded it twice.
  /Nisse
 
 I've tested it again, from scratch with Notepad editor:
 
 echoUTF8.php?php require(echoUTF8sub.php); ?
 echoUTF8sub.php   ?php echo test; ?
 and keep getting strange characters.
 
 Would you be so kind to run these 2 scripts on your pc ?
 
 TIA, Cor
 
 
 
Erm, what scripts?...


Ash
www.ashleysheridan.co.uk


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: require() causing strange characters ?

2009-02-08 Thread Nisse Engström
On Fri, 6 Feb 2009 10:11:49 +0100, cr.vege...@gmail.com wrote:

 I saved both scripts with ANSI in stead of UTF-8 and the problem is gone.
 So the utf-8 BOM character (Byte Order Mark) caused it.
 Unfortunately my editor has no option to store BOM-free scripts.
 
 Is it standard that PHP scripts should be saved without a BOM character ?

This is not a PHP matter, unless PHP 6 (which will have
Unicode support) does something with it. PHP 5 just outputs
it as is.

A BOM character is supposed to be the *first* character in
a text stream. Otherwise it should be treated as a
ZERO WIDTH NON-BREAKING SPACE.

http://unicode.org/faq/utf_bom.html#bom1

 Test results ...
 If test.php (utf8) requires echo.php (utf8), page source has C�testD, 
 size 9
 If test.php (ansi) requires echo.php (utf8), page source has 
 CtestD, size 7
 If test.php (ansi) requires echo.php (ansi), page source has CtestD, 
 size 6
 
 The reason for asking is that sometimes  is displayed on some pages.

That means you've used a utf-8 BOM in a page using an 8-bit
character encoding (eg. iso-8859-1 or similar), or that you
have utf-8 encoded it twice.


/Nisse

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: require() causing strange characters ?

2009-02-06 Thread Nisse Engström
On Fri, 6 Feb 2009 06:34:41 +0100, cr.vege...@gmail.com wrote:

 I have a script called test.php:
 ?php echo C; require(echo.php); echo D; ?
 
 and a script called echo.php:
 ?php echo test; ?
 
 With IE and Firefox it shows: CtestD
 but when I view the source, it seems to be: C�testD
 
 When debugging it, it seems that:
 CtestD   has length 9 in stead of 6
 pos1has char=C ord=67 
 pos2has char=� ord=239 
 pos3has char=� ord=187 
 pos4has char=� ord=191 
 rest okay ...
 
 Any idea what's causing this and how to solve it ?

echo.php has a utf-8 BOM character (Byte Order Mark).
See if your editor has an option to store it without a BOM.


/Nisse

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: require() causing strange characters ?

2009-02-06 Thread cr.vegelin

Thanks Paul  Nisse,

I saved both scripts with ANSI in stead of UTF-8 and the problem is gone.
So the utf-8 BOM character (Byte Order Mark) caused it.
Unfortunately my editor has no option to store BOM-free scripts.

Is it standard that PHP scripts should be saved without a BOM character ?

Test results ...
If test.php (utf8) requires echo.php (utf8), page source has C�testD, 
size 9
If test.php (ansi) requires echo.php (utf8), page source has 
CtestD, size 7
If test.php (ansi) requires echo.php (ansi), page source has CtestD, 
size 6


The reason for asking is that sometimes  is displayed on some pages.

Regards, Cor


- Original Message - 
From: Nisse Engström news.nospam.0ixbt...@luden.se

To: php-general@lists.php.net
Sent: Friday, February 06, 2009 9:21 AM
Subject: [PHP] Re: require() causing strange characters ?



On Fri, 6 Feb 2009 06:34:41 +0100, cr.vege...@gmail.com wrote:


I have a script called test.php:
?php echo C; require(echo.php); echo D; ?

and a script called echo.php:
?php echo test; ?

With IE and Firefox it shows: CtestD
but when I view the source, it seems to be: C�testD

When debugging it, it seems that:

CtestD   has length 9 in stead of 6
pos1has char=C ord=67
pos2has char=� ord=239
pos3has char=� ord=187
pos4has char=� ord=191
rest okay ...


Any idea what's causing this and how to solve it ?


echo.php has a utf-8 BOM character (Byte Order Mark).
See if your editor has an option to store it without a BOM.


/Nisse

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php