Solved

Php file utf 8 problem?

Posted on 2007-12-06
2
627 Views
Last Modified: 2008-02-01
Ok,
 I have in my mysql database utf 8  and bunch of characters what are not supported by PHP.
I wanted to make some language file in my script and I cant write some special chars. Wenn I save the file it looks file, wenn I open it , it looks screwed up.
For example:

$language]['Austria'] = "Österreich";

Can I write directly in some php variable chars like üäö , I don want to write this ü ä ö

So my question is, is possible to write some php characters in php file directly?
0
Comment
Question by:galic1987
2 Comments
 
LVL 20

Expert Comment

by:steelseth12
ID: 20419405
Make sure that you page that displays the characters has the correct encoding.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Also if you are opening the file with fopen use binary mode.

E.g

fopen("file.txt","rb");
0
 
LVL 19

Accepted Solution

by:
SteveH_UK earned 500 total points
ID: 20419426
PHP code does not support Unicode characters natively (at least not in PHP <= 5).

However, you could preload text from a file into an array and treat it as binary.

If you do this, make sure you don't get caught out by Byte-Order-Marks (BOMs) at the beginning of the files.

We did this to support a country list.  I've used Unicode extensively in PHP 4, with custom code.
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question