This example should show how encoding works. It is a test bench to check the parser at the same time.
Encoding is the definition, which bit pattern are used for the textual readable chars in a file. See http://en.wikipedia.org/wiki/Character_encoding. Encoding and Coding is used for 3 processes:
Encoding of the ZBNF-Script-file
Encoding of the Input to parse
Decoding of the outputted XML-file from Zbnf2Xml
It is possible to write the ZBNF-script with any character set, process input files which other character sets and generate XML with a third character set. The encodings are determined by the generating and using processes outside of the parser. Thats why several encodings should be work.
A often used encoding is UTF-8. But this character code may need more as one byte for special chars. On windows the typical country-specific 8-bit-character sets are used. Foreign character sets at example the Cyrillic alphabet or japanese should work.
The example contains:
del_results.bat testEncodings.bat testEncodings.zbnf input_UTF8.txt output.reference.xml outputASCII.reference.xml outputUTF8.reference.xml
del_results.bat: helper to clean.
testEncodings.bat: Windows-batch file to invoke parsings using Zbnf2Xml.
input_UTF8.txt: A text file which should be parsed.
testEncodings.zbnf: The ZBNF-syntax of the textfile.
*.reference.xml: The expected result in some encodings: Test results with changed conditions should be compared with it.
testEncodings.bat is invoked, the following files should be created:
output.xml outputASCII.xml outputUTF8.xml