unicode char in fwrite()

General discussions related to php

Moderators: macek, egami, gesf

cowchops
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Oct 11, 2012 12:37 am

unicode char in fwrite()

Postby cowchops » Thu Oct 11, 2012 12:38 am

Hi Everyone,

I've been searching Google for quite some time and I'm struggling to find an answer to this that actually works... I'm trying to write the "Double Dagger" unicode character 2021 (see: http://www.fileformat.info/info/unicode ... /index.htm) to a text file but I'm struggling. I don't have any experience with text encoding, so I'm not entirely sure whether I should be trying to generate the character in a specific format, or convert the whole file to unicode?

So far I've tried including a UTF header, using utf8_encode(), using mb_convert_encoding() and none of them seem to do the job. Can anyone help?

code (this doesn't actually work):

Code: Select all

$str1 = pack("C", 0xE2, 0x80, 0xA1);
$myString = "The Double Dagger Character:".$str1;

$fh=fopen('testUTF.txt',"wb");

$myString=utf8_encode($myString);
$myString="\xEF\xBB\xBF".$myString.$str1;

fwrite($fh,$myString);
fclose($fh);


thanks :)

Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron