fixed encoding

git-svn-id: trunk@15771 -
This commit is contained in:
mattias 2008-07-13 20:52:25 +00:00
parent 5bd40abaab
commit ebd4d40039
3 changed files with 48 additions and 22 deletions

View File

@ -42,7 +42,7 @@ unit SynEditTypes;
interface
const
TSynSpecialChars = ['À'..'Ö', 'Ø'..'ö', 'ø'..'ÿ'];
TSynSpecialChars = ['À'..'Ö', 'Ø'..'ö', 'ø'..'ÿ'];
TSynValidStringChars = ['_', '0'..'9', 'A'..'Z', 'a'..'z'] + TSynSpecialChars;
TSynWhiteChars = [' ', #9];
TSynWordBreakChars = ['.', ',', ';', ':', '"', '''', '!', '?', '[', ']', '(',

View File

@ -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
--------------------------------------------------------------}

View File

@ -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 (i<p) do begin
if s[i] in [#10,#13] then begin
inc(i);
x:=1;
inc(y);
if (i<=length(s)) and (s[i] in [#10,#13]) and (s[i]<>s[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;