Jump to content

[Solved]_How to create UTF File?


Recommended Posts

First problem is that if I paste or try to write something into the scite all isee is ????? & this is a problem.

If I try to create file with mode 32 the file is created, but nothing is written into the file

If I create a UTF-8 file with notpad & use filewrite, it works

This is what im trying to do

$string  = 'Russian string'
$string2 = 'Japaneese string'

Dircreate($string)
FileWriteLine($string & '\text.txt', $string2)

EIDT: See posts 9,10,11 for solution & remarks

Edited by goldenix
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

  • Developers

Have you set the file encoding in SciTE for the file you have open?

The created UTF files you need to use the FileOpen() command with the proper parameters.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Have you set the file encoding in SciTE for the file you have open?

The created UTF files you need to use the FileOpen() command with the proper parameters.

Jos

How can I set the File encoding?

This is How I tried it, instead strings I used Clipget()

$file = FileOpen("test.txt", 1)
FileClose($file)

$file = FileOpen("test.txt", 32)

$string  = 'Russian string'
$string2 = 'Japaneese string'

Dircreate($string)
FileWriteLine($string & '\text.txt', $string2)

FileClose($file)
Edited by goldenix
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

  • Developers

In SciTE Under the File option you will find the Encoding option.

Have you read the helpfile FileOpen() function? You need to use the retuned filehandle.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

In SciTE Under the File option you will find the Encoding option.

Have you read the helpfile FileOpen() function? You need to use the retuned filehandle.

Jos

Where can i set the default (Code Page Property) Encoding to UTF? Its real pain to change encodig each time I open a file. :)

This Wont create the file this is why I created one with foleopen mode 1 but it did not write anything into the file after I opened the file with mode 32. this is why I asked.

$file = FileOpen("test.txt", 32)

FileWriteLine($file, ClipGet())

FileClose($file)
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

Where can i set the default (Code Page Property) Encoding to UTF? Its real pain to change encodig each time I open a file. :)

This Wont create the file this is why I created one with foleopen mode 1 but it did not write anything into the file after I opened the file with mode 32. this is why I asked.

Mode 32 = 32 + 0, and 0 is READ. Try 32 + 1 for WRITE.

:P

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

32+1 does create the file now, but after I set Encoding to UTF (I tried with other encodings also) it still does not work see the result I get:

Results in:

$file = FileOpen("test.txt", 128+1)
$string2 = 'Каталог'
FileWriteLine($file, $string2)
FileClose($file)

ÐаÑалог ÑайÑов

Note, that when i use clipget the string it does write the string to the file in its original format.

FileWriteLine($file, ClipGet())
Edited by goldenix
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

When I paste 'Каталог' in an .au3 file already open SciTE, I get '???????'.

But if I run this first:

$sFile = "C:\Temp\Test.au3"
$hFile = FileOpen($sFile, 32+1)
FileWriteLine($hFile, @CRLF)
FileClose($hFile)

Then, I open Test.au3 in SciTE and paste it in, and I get 'Каталог'.

So the problem is that the first file was already opened with a different encoding. Creating the file first set the flag bytes in the beginning of the file for unicode, and when I opened that file SciTE recognized it and uses it.

:)

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

Mode 32 = 32 + 0, and 0 is READ. Try 32 + 1 for WRITE.

:)

aha okey so the Encoding option under file->Encoding does not work(Encoding is not applied when running the code) & the only way to write some foreign text into a file goes like this:

But is it really a bug now?

1) Create Empty myfile.au3 using code provided by PsaltyDS:

$sFile = "myfile.au3"
$hFile = FileOpen($sFile, 32+1)
FileWriteLine($hFile, @CRLF)
FileClose($hFile)
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

aha okey so the Encoding option under file->Encoding does not work(Encoding is not applied when running the code) & the only way to write some foreign text into a file goes like this:

But is it really a bug now?

1) Create Empty myfile.au3 using code provided by PsaltyDS:

$sFile = "myfile.au3"
$hFile = FileOpen($sFile, 32+1)
FileWriteLine($hFile, @CRLF)
FileClose($hFile)

2) Now insert sample code into myfile.au3 and run it:

$file = FileOpen("Test.txt", 32+1)
$string2 = 'γειά σου'
FileWriteLine($file, $string2)
FileClose($file)
I don't think there is any bug here, I was only showing that an already open file might behave differently than opening one that already has encoding selected.

Back to the first file, already open, that wouldn't show the cyrilic characters; If I click File/Encoding/UCS-2 Little Endian, then I can get the proper characters there too, as Jos pointed out earlier.

There are properties files for SciTE where you can set the default encoding. I haven't had to do it, so I don't know exactly which ones. Maybe code.page and output.code.page. Find the right one and you should be able to have unicode as your default for new files. From the help file:

There are four properties files used:

Local properties file called "SciTE.properties" which may be present in the same directory as the file being edited.

Directory properties file called "SciTEDirectory.properties" which may be present in the same or in a parent directory as the file being edited.

User properties file called "SciTEUser.properties" on Windows and ".SciTEUser.properties" on GTK+

Global properties file called "SciTEGlobal.properties"

The remaining issue would be if you open a script previously saved in ANSI or some such. I think SciTE would detect the encoding and run with that (even if unicode was set in properties) unless forcibly overridden by you with File/Encoding.

:)

Edit: fixed quoted portion.

Edited by PsaltyDS
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

I found this: but even after I tried to remove # from this line & comment out #code.page=0 its still not in unicode after launching scite.

SciTe\SciTEGlobal.properties
================================
line: | 233 | #LC_CTYPE=en_US.UTF-8

I tried this:

1) make a file in Ansi (default) testfile.au3 & open it in SciTe

2) Chage encoding in SciTe to UTF-8

3) Type in some Foreign text & save your testfile.au3

4) Now open your testfile.au3, as you can see It was not saved as in UTF-8 format, even tho it should have been, since you changed the encoding earlier.

Edited by goldenix
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
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...