[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Php file utf 8 problem?

Posted on 2007-12-06
2
Medium Priority
?
638 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 1500 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.
Suggested Courses
Course of the Month18 days, 1 hour left to enroll

829 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