OpenPetra
Free Administration Software for Non-Profits
|
Static Public Member Functions | |
static void | RecurseFilesAndDirectories (string APath, string AExt, ProcessFileType func) |
todo: exclude directory names, e.g. CSV, see BuildTools\ProgressConverter\AnalyseProgressFiles.cs More... | |
static void | Dos2Unix (String filename) |
remove carriage return More... | |
static void | Unix2Dos (String filename) |
add carriage return More... | |
static void | ConvertToUnicode (String AFilename, String AEncodingCodePage) |
convert a text file from a given code page to Unicode More... | |
static bool | SameContent (String filename1, String filename2, bool AIgnoreNewLine=true, SortedList< string, string >AToReplace=null, bool AWithLogging=false) |
check if the two text files have the same content if AIgnoreNewLine is true: if there are multiple percentage characters in the first file, then ignore the text in that position More... | |
static string | Diff (String TextA, String TextB) |
very simple function to show the difference of two texts More... | |
static bool | UpdateFile (String AOrigFilename, bool AIgnoreNewLine=false) |
this will compare the original file with the file that has the same name but an extension .new additionally at the end if the files have identical content, the new file is dropped otherwise new file is renamed to the original file name. there is no backup. More... | |
static Encoding | GetFileEncoding (String AFilename, Encoding ADefaultEncoding=null) |
static bool | AutoDetectTextEncodingAndOpenFile (string AFilename, out String AText, out Encoding AEncoding, out bool AHasBOM, out bool AIsAmbiguousUTF, out byte[] ARawBytes, int ATestByteCount=0) |
Function to detect the encoding for UTF-7, UTF-8/16/32 (bom, no bom, little or big endian), and local default codepage More... | |
Some useful functions for dealing with text files; only used for BuildTools at the moment
|
inlinestatic |
Function to detect the encoding for UTF-7, UTF-8/16/32 (bom, no bom, little or big endian), and local default codepage
AFilename | Filename to open |
AText | The content of the file using the discovered encoding. |
AEncoding | The discovered encoding. One of the six UTF options or the user's default ANSI code page. |
AHasBOM | Will be set to true if the file has a BOM header |
AIsAmbiguousUTF | Will be set to true if the text that the method outputs is ambiguous. This will be true if the determination of the UTF format was statistically not significant |
ARawBytes | The raw bytes read from the file. This can be used to display alternative text for ambiguous options |
ATestByteCount | Number of bytes to check of the file (to save processing). Higher value is slower, but more reliable (especially UTF-8 with special characters later on may appear to be ASCII initially). If ATestByteCount = 0, then ATestByteCount becomes the length of the file (for maximum reliability). |
|
inlinestatic |
convert a text file from a given code page to Unicode
AFilename | |
AEncodingCodePage |
|
inlinestatic |
very simple function to show the difference of two texts
|
inlinestatic |
remove carriage return
|
inlinestatic |
StreamReader DetectEncodingFromByteOrderMarks does not work for ANSI? therefore we have to detect the encoding by comparing the first bytes of the file
|
inlinestatic |
todo: exclude directory names, e.g. CSV, see BuildTools\ProgressConverter\AnalyseProgressFiles.cs
|
inlinestatic |
check if the two text files have the same content if AIgnoreNewLine is true: if there are multiple percentage characters in the first file, then ignore the text in that position
|
inlinestatic |
add carriage return
|
inlinestatic |
this will compare the original file with the file that has the same name but an extension .new additionally at the end if the files have identical content, the new file is dropped otherwise new file is renamed to the original file name. there is no backup.
the intention is to generate code, but not to touch it for VCS if not necessary
AOrigFilename | the original name of the file |
AIgnoreNewLine | should ignore line break character differences |