Jump to content

how to write file in UTF-8?


rojiblanco
 Share

Recommended Posts

i'm making with file contains japanese characters. when i read , the result is correct. But when i write this result to a another file,it is wrong(in this file all japanese characters are displayed "???").I used write mode in UTF-8.

This is my code contains above operations:

;READ FILE
        $file = FileOpen($filePath,0)
    $linestring = FileReadLine($file,1)
    $arrInputData = StringSplit($linestring,",")
    $arrInputData[0] = $arrInputData[1]
    FileClose($file)
...........
       ;WRITE FILE
        $string = _ArrayToString($arrInputData,",",0,6)
    _FileCreate($ResultFilePath)
    $file = FileOpen($ResultFilePath,129)
    FileWriteLine($ResultFilePath,$string)
    FileClose($file)

i think this failed in function FileWriteLine

Please give me a correct method

Thanks alot!

Link to comment
Share on other sites

i'm making with file contains japanese characters. when i read , the result is correct. But when i write this result to a another file,it is wrong(in this file all japanese characters are displayed "???").I used write mode in UTF-8.

This is my code contains above operations:

;READ FILE
        $file = FileOpen($filePath,0)
    $linestring = FileReadLine($file,1)
    $arrInputData = StringSplit($linestring,",")
    $arrInputData[0] = $arrInputData[1]
    FileClose($file)
...........
      ;WRITE FILE
        $string = _ArrayToString($arrInputData,",",0,6)
    _FileCreate($ResultFilePath)
    $file = FileOpen($ResultFilePath,129)
    FileWriteLine($ResultFilePath,$string)
    FileClose($file)

i think this failed in function FileWriteLine

Please give me a correct method

Thanks alot!

Never mix file operations using a string path with file operations using the file handle. FileOpen() returns the handle to $file, and the write after that should be:
$file = FileOpen($ResultFilePath,129)
    FileWriteLine($file,$string)

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...