MATLAB COMPILER RELEASE NOTES User's Guide Page 650

  • Download
  • Add to my manuals
  • Print
  • Page
    / 716
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 649
R2006a
22-20
Changes to Character Encoding in File I/O
The fopen function has a new optional argument, a string that specifies a name or alias
for the character encoding scheme associated with the file. If this argument is omitted
or is the empty string (''), the MATLAB default encoding scheme is used. Given a file
identifier as the only argument, fopen now returns an additional output value, a string
that identifies the character encoding scheme associated with the file.
Low-level file I/O functions that read data from files, including fread, fscanf, fgetl, and
fgets, read characters using the encoding scheme associated with the file during the call
to fopen. Low-level file I/O functions that write data, including fwrite and fprintf, write
characters using the encoding scheme associated with the file during the call to fopen.
Support for character encoding schemes has these limitations:
Surrogate pairs are not supported. Each surrogate pair is read as a replacement
character, the equivalent of char(26).
Stateful character encoding schemes are not supported.
Byte order marks are not interpreted in any special way. Your code must skip them if
necessary.
Scanning numbers, using fscanf, is supported only for character encoding schemes
that are supersets of ASCII. (Most popular character encoding schemes, with the
exception of UTF-16, are such supersets.)
Compatibility Considerations
In V7.1 (R14SP3), low-level file I/O functions that read and write data treated
characters as unsigned bytes. Programs using such functions as fread may have called
native2unicode to convert input to MATLAB characters using a particular encoding
scheme. Programs using such functions as fwrite may have called unicode2native to
convert output from MATLAB characters using a particular encoding scheme.
For example, on a Japanese Windows platform, where the default character encoding
scheme is Shift-JIS, a program may have used native2unicode and unicode2native
to read and write Japanese text in this way:
fid = fopen(file);
data = fread(fid, '*char')';
fclose(fid);
dataU = native2unicode(data);
Page view 649
1 2 ... 645 646 647 648 649 650 651 652 653 654 655 ... 715 716

Comments to this Manuals

No comments