diff options
author | s_alexander <s_alexander@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2009-12-05 12:26:00 +0000 |
---|---|---|
committer | s_alexander <s_alexander@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2009-12-05 12:26:00 +0000 |
commit | d589e6221ffcafc077eeefaa60cdc3e33a800558 (patch) | |
tree | c466f21bcbfa9546a7249b8ed2093e1bf84eeae2 /src/base/UTextEncoding.pas | |
parent | e0d74e92c0c7aa5b4e0fd7ee5fae0bff8e513a27 (diff) | |
download | usdx-d589e6221ffcafc077eeefaa60cdc3e33a800558.tar.gz usdx-d589e6221ffcafc077eeefaa60cdc3e33a800558.tar.xz usdx-d589e6221ffcafc077eeefaa60cdc3e33a800558.zip |
added autodetection of utf8
used w3c regex to match all song lines whether they are utf8 lines and
decode it on match as utf8 and as latin1 otherwise
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1964 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src/base/UTextEncoding.pas')
-rw-r--r-- | src/base/UTextEncoding.pas | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/base/UTextEncoding.pas b/src/base/UTextEncoding.pas index bb3d0f1a..79e5a297 100644 --- a/src/base/UTextEncoding.pas +++ b/src/base/UTextEncoding.pas @@ -42,7 +42,9 @@ type encLocale, // current locale (needs cwstring on linux) encUTF8, // UTF-8 encCP1250, // Windows-1250 Central/Eastern Europe (used by Ultrastar) - encCP1252 // Windows-1252 Western Europe (used by UltraStar Deluxe < 1.1) + encCP1252, // Windows-1252 Western Europe (used by UltraStar Deluxe < 1.1) + encAuto // try to match the w3c regex and decode as unicode on match + // and as fallback if not match ); const @@ -88,7 +90,9 @@ function EncodingName(Encoding: TEncoding): AnsiString; implementation uses - StrUtils; + StrUtils, + pcre, + ULog; type IEncoder = interface @@ -229,6 +233,7 @@ end; {$I ../encoding/UTF8.inc} {$I ../encoding/CP1250.inc} {$I ../encoding/CP1252.inc} +{$I ../encoding/Auto.inc} initialization Encoders[encLocale] := TEncoderLocale.Create; @@ -236,4 +241,7 @@ initialization Encoders[encCP1250] := TEncoderCP1250.Create; Encoders[encCP1252] := TEncoderCP1252.Create; + // use USDX < 1.1 encoding for backward compatibility (encCP1252) + Encoders[encAuto] := TEncoderAuto.Create(Encoders[encUTF8], Encoders[encCP1252]); + end. |