FileEncoding
PowerScript function
Description
Checks the encoding of the specified file.
Syntax
|
1 |
FileEncoding ( filename ) |
|
Argument |
Description |
|---|---|
|
filename |
The name of the file you want to test for encoding |
Return value
A value of the enumerated datatype encoding. Values are:
EncodingANSI!
EncodingUTF8!
EncodingUTF16LE!
EncodingUTF16BE!
If filename does not exist, returns null.
Usage
Use this function to determine the encoding used in an external file
before attempting to use it in a PowerBuilder application.
Examples
The following example opens a file in stream mode and tests to
determine whether it uses ANSI encoding. If it does, it reads data from
the file into a blob and uses the String function to convert the blob to a
Unicode string:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
long ll_filenum integer li_bytes string ls_unicode blob lb_ansi encoding eRet ll_filenum = FileOpen("employee.dat", StreamMode!, Read!, LockWrite!, Replace!) // test the file's encoding eRet = FileEncoding("employee.dat") if eRet = EncodingANSI! then li_ bytes = FileReadEx(ll_filenum, lb_ansi) ls_unicode = string(lb_ansi, EncodingANSI!) else li_ bytes = FileReadEx(ll_filenum, ls_unicode) end if FileClose(ll_filenum) |
See also
Document get from Powerbuilder help
Thank you for watching.
Subscribe
Login
0 Comments
Oldest