Convert to Unicode

Aus MHC-Wiki

Wechseln zu: Navigation, Suche

export to file

A common task is creating text files by "export to file"

Prompt for print or export file
Prepare for export to file {One field per line}
Export data ivOutput
End export
Close print or export file

With the unicode version of Omnis 3 bytes will prepended to the output. These 3 bytes are a code which is used by Omnis when the file is read to determin the used byte order. To supress this set the poperty of:

$exportbom

to "kFalse" at

$root.$prefs


readfile

Replace $readfile with $readcharacter.


sys(2)

With non unicode verisons the 4th bit is not set so you can check sys(2) easylie by comparing the result with integers. You can still do this by precomputing the correct integer values, but there is a more transparent way to do this:

Help reads: Returns the Omnis program type byte:

bit 0 = full program (value 1),
bit 1 = runtime (value 2),
bit 2 = evaluation (value 4),
bit 3 = integrated (value 8),
bit 4 = Unicode (value 16).

Note that the current version of Omnis does not support the use of integrated versions.

Best way to check for a certain version is to use "bittest":

dev         ->  bittest(binfromlong(sys(2));31;31)
runtime     ->  bittest(binfromlong(sys(2));30;30)
evaluation  ->  bittest(binfromlong(sys(2));29;29)
integrated  ->  bittest(binfromlong(sys(2));28;28)
unicode     ->  bittest(binfromlong(sys(2));27;27)

Should work, but due to a bug in 4.3 it does not. The workaround is:

Calculate sys2 as binfromlong(sys(2))   ;; sys2 is a binary var
... bittest(sys2;31;31) ...

And: Yes, 31, 30, 29, etc. is correct, and not as you may expect 0, 1, 2, 3, etc. "bittest" misinterprets binary data and starts counting MSB as 0 instead of LSB.

Persönliche Werkzeuge
Navigation