From ebd4d400390280f4f1f2c27ba955843d6f19bdce Mon Sep 17 00:00:00 2001 From: mattias Date: Sun, 13 Jul 2008 20:52:25 +0000 Subject: [PATCH] fixed encoding git-svn-id: trunk@15771 - --- components/synedit/synedittypes.pp | 2 +- components/synedit/synregexpr.pas | 28 ++++++++++----------- lcl/lconvencoding.pas | 40 ++++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 22 deletions(-) diff --git a/components/synedit/synedittypes.pp b/components/synedit/synedittypes.pp index 0c7bdae811..6cdf9e0a70 100644 --- a/components/synedit/synedittypes.pp +++ b/components/synedit/synedittypes.pp @@ -42,7 +42,7 @@ unit SynEditTypes; interface const - TSynSpecialChars = [''..'', ''..'', ''..'']; + TSynSpecialChars = ['À'..'Ö', 'Ø'..'ö', 'ø'..'ÿ']; TSynValidStringChars = ['_', '0'..'9', 'A'..'Z', 'a'..'z'] + TSynSpecialChars; TSynWhiteChars = [' ', #9]; TSynWordBreakChars = ['.', ',', ';', ':', '"', '''', '!', '?', '[', ']', '(', diff --git a/components/synedit/synregexpr.pas b/components/synedit/synregexpr.pas index 81012706ba..a768d5dc75 100644 --- a/components/synedit/synregexpr.pas +++ b/components/synedit/synregexpr.pas @@ -411,8 +411,8 @@ type property ModifierR : boolean index 2 read GetModifier write SetModifier; // Modifier /r - use r.e.syntax extended for russian, // (was property ExtSyntaxEnabled in previous versions) - // If true, then - additional include russian letter '', - // - additional include '', and - include all russian symbols. + // If true, then а-я additional include russian letter 'ё', + // А-Я additional include 'Ё', and а-Я include all russian symbols. // You have to turn it off if it may interfere with you national alphabet. // , initialized from RegExprModifierR @@ -1480,7 +1480,7 @@ procedure TRegExpr.Tail (p : PRegExprChar; val : PRegExprChar); // shr after subtraction to calculate widechar distance %-( ) // so, if difference is negative we have .. the "feature" :( // I could wrap it in $IFDEF UniCode, but I didn't because - // "P Q computes the difference between the address given + // "P – Q computes the difference between the address given // by P (the higher address) and the address given by Q (the // lower address)" - Delphi help quotation. else PRENextOff (scan + REOpSz)^ := val - scan; //###0.933 @@ -1591,17 +1591,17 @@ const #$418,#$419,#$41A,#$41B,#$41C,#$41D,#$41E,#$41F, #$420,#$421,#$422,#$423,#$424,#$425,#$426,#$427, #$428,#$429,#$42A,#$42B,#$42C,#$42D,#$42E,#$42F,#0); - RusRangeLoLow = #$430{''}; - RusRangeLoHigh = #$44F{''}; - RusRangeHiLow = #$410{''}; - RusRangeHiHigh = #$42F{''}; + RusRangeLoLow = #$430{'а'}; + RusRangeLoHigh = #$44F{'я'}; + RusRangeHiLow = #$410{'А'}; + RusRangeHiHigh = #$42F{'Я'}; {$ELSE} - RusRangeLo = ''; - RusRangeHi = 'Ũ'; - RusRangeLoLow = ''; - RusRangeLoHigh = ''; - RusRangeHiLow = ''; - RusRangeHiHigh = ''; + RusRangeLo = 'абвгдеёжзийклмнопрстуфхцчшщъыьэюя'; + RusRangeHi = 'АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ'; + RusRangeLoLow = 'а'; + RusRangeLoHigh = 'я'; + RusRangeHiLow = 'А'; + RusRangeHiHigh = 'Я'; {$ENDIF} function TRegExpr.CompileRegExpr (exp : PRegExprChar) : boolean; @@ -3621,7 +3621,7 @@ procedure TRegExpr.SetInputString (const AInputString : RegExprString); fInputStart := PChar (fInputString); Len := length (fInputString); fInputEnd := PRegExprChar (integer (fInputStart) + Len); ?? - !! startp/endp ? + !! startp/endp все равно будет опасно использовать ? } end; { of procedure TRegExpr.SetInputString --------------------------------------------------------------} diff --git a/lcl/lconvencoding.pas b/lcl/lconvencoding.pas index 73913baa67..fca1a6dcec 100644 --- a/lcl/lconvencoding.pas +++ b/lcl/lconvencoding.pas @@ -4422,12 +4422,7 @@ begin end; function GuessEncoding(const s: string): string; -var - l: Integer; - p: Integer; - EndPos: LongInt; - i: LongInt; - + function CompareI(p1, p2: PChar; Count: integer): boolean; var i: Integer; @@ -4450,6 +4445,37 @@ var Result:=true; end; + {$IFDEF VerboseIDEEncoding} + function PosToStr(p: integer): string; + var + y: Integer; + x: Integer; + i: Integer; + begin + y:=1; + x:=1; + i:=1; + while (i<=length(s)) and (is[i-1]) then + inc(i); + end else begin + inc(i); + inc(x); + end; + end; + Result:='x='+IntToStr(x)+',y='+IntToStr(y); + end; + {$ENDIF} + +var + l: Integer; + p: Integer; + EndPos: LongInt; + i: LongInt; begin l:=length(s); if l=0 then begin @@ -4484,7 +4510,7 @@ begin //DebugLn(['GuessEncoding ',i,' ',DbgStr(s[p])]); if i=0 then begin {$IFDEF VerboseIDEEncoding} - DebugLn(['GuessEncoding non UTF-8 found at ',p,' ',dbgstr(copy(s,p-10,20))]); + DebugLn(['GuessEncoding non UTF-8 found at ',PosToStr(p),' ',dbgstr(copy(s,p-10,20))]); {$ENDIF} break; end;