PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
maciek4
Forum Commoner
Posts: 29 Joined: Tue Apr 04, 2006 8:17 am
Post
by maciek4 » Tue Apr 11, 2006 7:08 am
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?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Apr 11, 2006 7:23 am
The second line is UTF-16 it would appear.
maciek4
Forum Commoner
Posts: 29 Joined: Tue Apr 04, 2006 8:17 am
Post
by maciek4 » Tue Apr 11, 2006 7:25 am
feyd wrote: The second line is UTF-16 it would appear.
What does it mean UTF 16? How can I fix this UTF 16
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Apr 11, 2006 7:40 am
There's nothing wrong with it. It is a charater encoding like UTF-8 or Windows-1255 (or whatever it's called.)
maciek4
Forum Commoner
Posts: 29 Joined: Tue Apr 04, 2006 8:17 am
Post
by maciek4 » Tue Apr 11, 2006 7:58 am
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.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Apr 11, 2006 8:07 am
Some were stored in plain ASCII or UTF-8, others are UTF-16, I'd imagine.
mb_convert_encoding() may be of interest.