Page 1 of 1

wierd characters when displaying content of a file

Posted: Tue Apr 11, 2006 7:08 am
by maciek4
I have a txt file and when I display the content using echo some lines display correctly and some have wierd characters in between letters:

for example:

Code: Select all

<?php
echo $lines[1];
echo $lines[2];


as a result I am getting correctly displayed first line:
1st line: Product A
2nd line: between each letter there is a square P(square)r(square)o(square)d(square) etc.

What should I do to display it correctly and why is it doing that?

Posted: Tue Apr 11, 2006 7:23 am
by feyd
The second line is UTF-16 it would appear.

Posted: Tue Apr 11, 2006 7:25 am
by maciek4
feyd wrote:The second line is UTF-16 it would appear.
What does it mean UTF 16? How can I fix this UTF 16

Posted: Tue Apr 11, 2006 7:40 am
by feyd
There's nothing wrong with it. It is a charater encoding like UTF-8 or Windows-1255 (or whatever it's called.)

Posted: Tue Apr 11, 2006 7:58 am
by maciek4
feyd wrote:There's nothing wrong with it. It is a charater encoding like UTF-8 or Windows-1255 (or whatever it's called.)
Right ok, but I don't want those squares. Dont even understand how it works. Why are there no squares in the first line?

The txt file is as follows

Product A
some description bla bla bla
Product B
description
Product C
desctiption
.
.
.

in some of them there are squares, in others just text.

Posted: Tue Apr 11, 2006 8:07 am
by feyd
Some were stored in plain ASCII or UTF-8, others are UTF-16, I'd imagine.

mb_convert_encoding() may be of interest.