This documentation describes the Prokee module interface.
UTF-8 encoded text files my contain a BOM (Byte-Order-Mark) at the beginning of the file.
The BOM can be useful to recognize UTF-8 encoded files, but it is not required for decoding UTF-8 characters.
Removing the BOM, should do no harm to the readability of UTF-8 files by modern text editors.
In some situations, the unexpected existence of the BOM may lead to problems. E.g. if the contents of a file should be inserted into another file, the BOM my be copied as well and show up as invalid character within the new file. To avoid such problems, this module provides a function to remove the BOM from files.
Removes (or adds) the utf8 Byte-Order-Mark (BOM) from (to) files.
Signature:
int removebom_run(const char *filepath,const char *file_extensions,bool flat,bool restore,bool print_log)
Parameters:
| const char * | filepath | [IN] | Path to a file or directory. |
| const char * | file_extensions | [IN] | The filename extensions to search for. Multiple filename extensions have to be deliminated by a comma ','. |
| bool | flat | | true for non-recursive mode and false to recursively search through sub-directories. |
| bool | restore | | If restore is set to true, the function adds a BOM to files instead of removing it. |
| bool | print_log | | If print_log is set to true, the function generates some output to stdout. |
Return value:Returns 0.
Tests:
test1: Removes the BOM from a test file.
Test function:
removebom_run()
Removes (or adds) the utf8 Byte-Order-Mark (BOM) from (to) files.
Signature:
int removebom_run2(const char *filepath,char **file_extensions,bool flat,bool restore,bool print_log)
Parameters:
| const char * | filepath | [IN] | Path to a file or directory. |
| char ** | file_extensions | [IN] | The filename extensions to search for. This may be set to NULL, to allow any filename extension. If not set to NULL, file_extensions has to be a null-terminated sequence of pointers to null-terminated strings containing the filename extensions to look for. |
| bool | flat | | true for non-recursive mode and false to recursively search through sub-directories. |
| bool | restore | | If restore is set to true, the function adds a BOM to files instead of removing it. |
| bool | print_log | | If print_log is set to true, the function generates some output to stdout. |
Return value:Returns 0.
Runs
removebom as if it would be called from the command-line.
See
Commandline-Interface.
Signature:
int removebom::main(int argc,char **argv)
Parameters:
| int | argc | | The number of command-line parameters. |
| char ** | argv | [IN] | The command-line parameters. |
Return value:Exit status.