----------------------------------------------------------------------
--- Knud van Eeden --- 31 May 2009 - 08:48 am ------------------------

Computer: Editor: Text: TSE: File: Format: ASCII: Unicode: Operation: Convert: How to save an ASCII file as a Unicode file?

---

Unicode file is a file starting with the two bytes 0xFE, 0xFF
(or thus 2 bytes with decimal value 254 followed by 255)
followed by zero or more characters (always 2 bytes per character)

---

In the special case of an ASCII character, the first character will be its
ASCII value, and the second character will by definition always be ASCII zero.
That is the way Unicode has been designed.

---

So to convert from ASCII to Unicode:

 1. -In this program the 2 bytes are inserted in the beginning of the file

 2. -ASCII zero byte is inserted after each character in the file

===

Note:

The result has been tested for a few files only, and worked OK there.

 1. -Creating or loading some ASCII file

 2. -Then loading and saving the same ASCII file in TSE using this macro

 3. -Then loading and saving the same ASCII file in Notepad in Unicode format

 4. -The result was compared for differences

     1. -Visually in TSE using the hex editor in a horizontally split window
         with the two Unicode files created by Notepad and TSE loaded

     2. -Further were the two Unicode files tested using the

         Microsoft Windows API

          IsTextUnicode

         and passed that test as being Unicode.

===

Steps: Overview:

 1. -E.g. create the following program:

--- cut here: begin --------------------------------------------------
// PROC PROCFileSaveChangeConvertSaveAsciiToUnicode( STRING fileNameAsciiS, STRING fileNameUnicodeS ) // [file: source: savefitu.s]
--- cut here: end ---------------------------------------------------- 3. -Input the ASCII filename 4. -Input the Unicode filename in which to store the result 5. -Tested successfully on Microsoft Windows XP Professional (service pack 3), running TSE v4.x === Book: see also: === Diagram: see also: === File: see also: === File: version: control: see also: === Help: see also: === Image: see also: === Internet: see also: === Podcast: see also: === Record: see also: === Screencast: see also: === Table: see also: === Video: see also: === <version>1.0.0.0.3</version> ----------------------------------------------------------------------

Share |

This web page is created and maintained using the Semware TSE text editor