* Skip all surrogate values in for loops from low(word) to high(word)

git-svn-id: trunk@40560 -
This commit is contained in:
pierre 2018-12-15 21:06:01 +00:00
parent f7661c6fd4
commit 0846456ce4
32 changed files with 84 additions and 56 deletions

View File

@ -12,7 +12,7 @@ program tgetnumericvalue;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -44,6 +44,8 @@ begin
e := 1;
k := 0;
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if (TCharacter.GetUnicodeCategory(uc) in
[ TUnicodeCategory.ucDecimalNumber,

View File

@ -12,7 +12,7 @@ program tgetnumericvalue2;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -54,6 +54,8 @@ begin
e := 1;
k := 0;
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := strPrefix + UnicodeChar(i) + strPrefix;
if (TCharacter.GetUnicodeCategory(uc,locCharPos) in
[ TUnicodeCategory.ucDecimalNumber,

View File

@ -12,7 +12,7 @@ program tgetnumericvalue3;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;

View File

@ -12,7 +12,7 @@ program tgetunicodecategoriesurro;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;

View File

@ -12,7 +12,7 @@ program tiscontrol;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -56,6 +56,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if (TCharacter.GetUnicodeCategory(uc) = TUnicodeCategory.ucControl) then begin
if not TCharacter.IsControl(uc) then

View File

@ -12,7 +12,7 @@ program tiscontrol2;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -59,6 +59,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := strPrefix + UnicodeChar(i) + strPrefix;
if (TCharacter.GetUnicodeCategory(uc,locCharPos) = TUnicodeCategory.ucControl) then begin
if not TCharacter.IsControl(uc,locCharPos) then

View File

@ -12,7 +12,7 @@ program tisdigit3;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;

View File

@ -12,7 +12,7 @@ program tisdigit;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -49,6 +49,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if (TCharacter.GetUnicodeCategory(uc) = TUnicodeCategory.ucDecimalNumber) then begin
if not TCharacter.IsDigit(uc) then

View File

@ -12,7 +12,7 @@ program tisdigit2;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -52,6 +52,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := strPrefix + UnicodeChar(i) + strPrefix;
if (TCharacter.GetUnicodeCategory(uc,locCharPos) = TUnicodeCategory.ucDecimalNumber) then begin
if not TCharacter.IsDigit(uc,locCharPos) then

View File

@ -12,7 +12,7 @@ program tgetnumericvalue3;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;

View File

@ -12,7 +12,7 @@ program tishighsurrogate;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -36,11 +36,6 @@ begin
Halt(Acode);
end;
const
LOW_SURROGATE_BEGIN = Word($DC00);
LOW_SURROGATE_END = Word($DFFF);
HIGH_SURROGATE_BEGIN = Word($D800);
HIGH_SURROGATE_END = Word($DBFF);
var
e, i , k: Integer;
uc : UnicodeChar;

View File

@ -12,7 +12,7 @@ program tisletter;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -56,6 +56,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if (TCharacter.GetUnicodeCategory(uc) in
[ TUnicodeCategory.ucUppercaseLetter, TUnicodeCategory.ucLowercaseLetter,
@ -78,6 +80,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if not (TCharacter.GetUnicodeCategory(uc) in
[ TUnicodeCategory.ucUppercaseLetter, TUnicodeCategory.ucLowercaseLetter,

View File

@ -12,7 +12,7 @@ program tisletterordigit;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -63,6 +63,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if (TCharacter.GetUnicodeCategory(uc) in
[ TUnicodeCategory.ucUppercaseLetter, TUnicodeCategory.ucLowercaseLetter,
@ -79,6 +81,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if not (TCharacter.GetUnicodeCategory(uc) in
[ TUnicodeCategory.ucUppercaseLetter, TUnicodeCategory.ucLowercaseLetter,

View File

@ -12,7 +12,7 @@ program tislowsurrogate;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -36,11 +36,6 @@ begin
Halt(Acode);
end;
const
LOW_SURROGATE_BEGIN = Word($DC00);
LOW_SURROGATE_END = Word($DFFF);
HIGH_SURROGATE_BEGIN = Word($D800);
HIGH_SURROGATE_END = Word($DBFF);
var
e, i , k: Integer;
uc : UnicodeChar;

View File

@ -12,7 +12,7 @@ program tisnumber;
uses
SysUtils,
character;
unicodedata, character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -44,6 +44,8 @@ begin
e := 1;
k := 0;
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if TCharacter.IsNumber(uc) then begin
WriteLn('CodePoint = ',IntToHex(Ord(uc),4), ' ; IsNumber = ',TCharacter.IsNumber(uc));

View File

@ -12,7 +12,7 @@ program tisnumber2;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -47,6 +47,8 @@ begin
e := 1;
k := 0;
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := strPrefix + UnicodeChar(i) + strPrefix;
if TCharacter.IsNumber(uc,locCharPos) then begin
WriteLn('CodePoint = ',IntToHex(Ord(uc[locCharPos]),4), ' ; IsNumber = ',TCharacter.IsNumber(uc,locCharPos));

View File

@ -12,7 +12,7 @@ program tispunctuation;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -80,6 +80,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if (TCharacter.GetUnicodeCategory(uc) in
[ TUnicodeCategory.ucConnectPunctuation, TUnicodeCategory.ucDashPunctuation,

View File

@ -12,7 +12,7 @@ program tisseparator;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -60,6 +60,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if (TCharacter.GetUnicodeCategory(uc) in
[ TUnicodeCategory.ucSpaceSeparator,
@ -75,6 +77,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if not (TCharacter.GetUnicodeCategory(uc) in
[ TUnicodeCategory.ucSpaceSeparator,

View File

@ -12,7 +12,7 @@ program tissurrogate;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;

View File

@ -12,7 +12,7 @@ program tissurrogatepair;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -28,13 +28,6 @@ begin
Halt(Acode);
end;
const
LOW_SURROGATE_BEGIN = Word($DC00);
LOW_SURROGATE_END = Word($DFFF);
HIGH_SURROGATE_BEGIN = Word($D800);
HIGH_SURROGATE_END = Word($DBFF);
var
e, i , j: Integer;
begin

View File

@ -12,7 +12,7 @@ program tissurrogatepair2;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -28,13 +28,6 @@ begin
Halt(Acode);
end;
const
LOW_SURROGATE_BEGIN = Word($DC00);
LOW_SURROGATE_END = Word($DFFF);
HIGH_SURROGATE_BEGIN = Word($D800);
HIGH_SURROGATE_END = Word($DBFF);
var
e, i , j: Integer;
s : UnicodeString;

View File

@ -12,7 +12,7 @@ program tissymbol;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -89,6 +89,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if (TCharacter.GetUnicodeCategory(uc) in
[ TUnicodeCategory.ucMathSymbol,
@ -105,6 +107,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if not (TCharacter.GetUnicodeCategory(uc) in
[ TUnicodeCategory.ucMathSymbol,

View File

@ -12,7 +12,7 @@ program tisupper;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -56,6 +56,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if (TCharacter.GetUnicodeCategory(uc) = TUnicodeCategory.ucUppercaseLetter) then begin
if not TCharacter.IsUpper(uc) then
@ -65,6 +67,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if (TCharacter.GetUnicodeCategory(uc) <> TUnicodeCategory.ucUppercaseLetter) then begin
if TCharacter.IsUpper(uc) then

View File

@ -12,7 +12,7 @@ program tiswhitespace;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -86,6 +86,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if (TCharacter.GetUnicodeCategory(uc) in
[ TUnicodeCategory.ucSpaceSeparator,

View File

@ -12,7 +12,7 @@ program tlowercase;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -56,6 +56,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if (TCharacter.GetUnicodeCategory(uc) = TUnicodeCategory.ucLowercaseLetter) then begin
if not TCharacter.IsLower(uc) then
@ -65,6 +67,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if (TCharacter.GetUnicodeCategory(uc) <> TUnicodeCategory.ucLowercaseLetter) then begin
if TCharacter.IsLower(uc) then

View File

@ -12,7 +12,7 @@ program tlowercase2;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -65,6 +65,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := strPrefix + UnicodeChar(i) + strPrefix;
if (TCharacter.GetUnicodeCategory(uc,locCharPos) = TUnicodeCategory.ucLowercaseLetter) then begin
if not TCharacter.IsLower(uc,locCharPos) then
@ -74,6 +76,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := strPrefix + UnicodeChar(i) + strPrefix;
if (TCharacter.GetUnicodeCategory(uc,locCharPos) <> TUnicodeCategory.ucLowercaseLetter) then begin
if TCharacter.IsLower(uc,locCharPos) then

View File

@ -12,7 +12,7 @@ program ttolower;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -65,6 +65,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if (TCharacter.GetUnicodeCategory(uc) = TUnicodeCategory.ucLowercaseLetter) then begin
if (TCharacter.ToLower(uc) <> uc) then

View File

@ -12,7 +12,7 @@ program ttolower2;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;

View File

@ -12,7 +12,7 @@ program ttolower3;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;

View File

@ -12,7 +12,7 @@ program ttoupper;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;
@ -65,6 +65,8 @@ begin
Inc(e);
for i := Low(Word) to High(Word) do begin
{ Skip all surrogate values }
if (i>=HIGH_SURROGATE_BEGIN) and (i<=LOW_SURROGATE_END) then continue;
uc := UnicodeChar(i);
if (TCharacter.GetUnicodeCategory(uc) = TUnicodeCategory.ucUppercaseLetter) then begin
if (TCharacter.ToUpper(uc) <> uc) then

View File

@ -12,7 +12,7 @@ program ttoupper2;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;

View File

@ -12,7 +12,7 @@ program ttoupper3;
uses
SysUtils,
character;
unicodedata,character;
{$ifndef FPC}
type UnicodeChar = WideChar;