Jump to content

Save as Unicode txt file


web_master

Recommended Posts

Hi, I got a problem, how can I save an utf-8 txt into Unicode txt file same time when I sent it to dBase.

 

I connect to dBase like this:

 

<?php
mysql_connect("localhost","root","") or die("Can’t connect to SQL server");
mysql_select_db("dbase") or die("Can’t connect to DataBase");
mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8');
?>

 

 

than I sent the text into dBase:

 

 

<?php
$query = mysql_query("INSERT INTO `text_table` (`text`) VALUES (' ".$_POST['text']." ') ");
?>

 

So, I use a utf-8 charset, and I want to when the "text" go into dbase to go into one txt-file to with a Unicode characterset.

 

thanx

Link to comment
https://forums.phpfreaks.com/topic/139539-save-as-unicode-txt-file/
Share on other sites

I think you just have to translate your data into utf-8 string like:

<?php
   $theText = utf8_encode($_POST['text']);
   $query = mysql_query("INSERT INTO `text_table` (`text`) VALUES (' $theText ') ");
   $fileHandle = fopen("file.txt", "wb");
   fwrite($fileHandle, $theText);
   fclose($fileHandle);
?>

 

 

----------------

Now playing: D-Phrag - Deep Transmissions Part 3

via FoxyTunes

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.