fopen user guide in MATLAB

 

refer to: http://cn.mathworks.com/help/symbolic/mupad_ref/fopen.html

    And: http://cn.mathworks.com/help/matlab/ref/fopen.html

 

Syntax

fopen(filename | TempFile, <Read | Write | Append>, <Bin | Text | Raw>, <Encoding = "encodingValue">)

 

Bin, Raw, Text

With Bin, the data is stored in MuPAD internal binary format. WithText, the data may be strings or MuPAD objects stored as text. Newlines are handled according to the conventions of the operating system at hand. WithRaw, the data is interpreted as binary machine numbers. See the functionsreadbytes andwritebytes.

If the mode is Read or Append, the default is the format of the data in the existing file. If the mode isWrite, the default isBin.

Encoding

This option lets you specify the character encoding to use. The allowed encodings are:

"Big5"

"ISO-8859-1"

"windows-932"

"EUC-JP"

"ISO-8859-2"

"windows-936"

"GBK"

"ISO-8859-3"

"windows-949"

"KSC_5601"

"ISO-8859-4"

"windows-950"

"Macintosh"

"ISO-8859-9"

"windows-1250"

"Shift_JIS"

"ISO-8859-13"

"windows-1251"

"US-ASCII"

"ISO-8859-15"

"windows-1252"

"UTF-8"

 

"windows-1253"

  

"windows-1254"

  

"windows-1257"

'Big5'

'ISO-8859-1'

'windows-847'

'Big5-HKSCS'

'ISO-8859-2'

'windows-949'

'CP949'

'ISO-8859-3'

'windows-1250'

'EUC-KR'

'ISO-8859-4'

'windows-1251'

'EUC-JP'

'ISO-8859-5'

'windows-1252'

'EUC-TW'

'ISO-8859-6'

'windows-1253'

'GB18030'

'ISO-8859-7'

'windows-1254'

'GB2312'

'ISO-8859-8'

'windows-1255'

'GBK'

'ISO-8859-9'

'windows-1256'

'IBM866'

'ISO-8859-11'

'windows-1257'

'KOI8-R'

'ISO-8859-13'

'windows-1258'

'KOI8-U'

'ISO-8859-15'

'US-ASCII'

 

'Macintosh'

'UTF-8'

 

'Shift_JIS'

 
 

The default encoding is system dependent. If you specify the encoding incorrectly, characters might read incorrectly. Characters unrecognized by the encoding are replaced by the default substitution character for the specified encoding.

Encodings not listed here can be specified but might not produce correct results.

Return Values

a positive integer: the file descriptor. FAIL is returned if the file cannot be opened.

 

Example

To specify the encoding to read and write data, use Encoding. TheEncoding option applies only to text files that are opened using a file name and not a file descriptor. Create a temporary file and write the string"abcäöü" in the encoding "UTF-8":

fid := fopen(TempFile, Text, Write, Encoding="UTF-8"):
file := fname(fid):
fprint(Unquoted, fid, "abcäöü"):
fclose(fid):

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值