end;
//\83V\83\8a\83A\8cê\83u\83\89\83N\83\89\91Î\8dô
function TAbon.TreatSyria(AString: string): string;
+const
+ UNI_TAG = '&#';
var
//count: Integer; //(܀~ݏ)
- pos: Integer;
- tmp: string;
-begin
- tmp := '';
- pos := AnsiPos('', AString);
- while pos <> 0 do begin
- tmp := tmp + Copy(AString, 1, pos - 1);
- Delete(AString, 1, pos -1);
- if StrToIntDef(Copy(AString, 4, 2), -1) > 0 then begin
- if (AString[7] = ';' ) or (AString[7] = ' ') then begin
- Delete(AString, 1, 7);
- end else if StrToIntDef(AString[7], -1) = -1 then begin
- Delete(AString, 1, 6);
- end else begin
- tmp := tmp + Copy(AString, 1, 6);
- Delete(AString, 1, 6);
- end;
- end else begin
- tmp := tmp + Copy(AString, 1, 7);
- Delete(AString, 1, 7);
- end;
- pos := AnsiPos('', AString);
- end;
- if Length(AString) > 0 then
- tmp := tmp + AString;
- AString := tmp;
- tmp := '';
-
- pos := AnsiPos('³', AString);
- while pos <> 0 do begin
- tmp := tmp + Copy(AString, 1, pos - 1);
- Delete(AString, 1, pos - 1);
- if StrToIntDef(Copy(AString, 6, 1), 0) > 2 then begin
- if (AString[7] = ';') or (AString[7] = ' ') then begin
- Delete(AString, 1, 7);
- end else if StrToIntDef(AString[7], -1) = -1 then begin
- Delete(AString, 1, 6);
+ ps : PChar;
+ p, pe, s, se : PChar;
+ scode: String;
+ icode: Integer;
+begin
+
+ Result := '';
+
+ p := PChar(AString);
+ pe := p + Length(AString);
+ s := PChar(UNI_TAG);
+ se := s + Length(UNI_TAG);
+
+ p := AnsiStrPosEx(p, pe, s, se);
+
+ while p <> nil do begin
+ //&#\82Ì\8eè\91O\82Ü\82Å\83R\83s\81[\82·\82é
+ Result := Result + Copy(AString, 1, p - PChar(AString));
+ //&#\82Ì\8eè\91O\82Ü\82Å\8dí\8f\9c\82·\82é
+ Delete(AString, 1, p - PChar(AString));
+
+ //AString\82É3\95¶\8e\9a\88È\8fã\82 \82ê\82Î\8e\9f\82Ì3\95¶\8e\9a\96Ú\82ð\83`\83F\83b\83N
+ if Length(AString) > 2 then begin
+ ps := PChar(AString) + 2;
+ if (ps^ = 'x') or (ps^ = 'X') then begin
+ //16\90i\95\\8bL
+ Inc(ps);
+ scode := '0x';
+ while ((ps^ >= '0') and (ps^ <= '9')) or
+ ((ps^ >= 'a') and (ps^ <= 'f')) or
+ ((ps^ >= 'A') and (ps^ <= 'F')) do begin
+
+ scode := scode + String(ps^);
+ Inc(ps);
+ end;
end else begin
- tmp := tmp + Copy(AString, 1, 5);
- Delete(AString, 1, 5);
+ //10\90i\95\\8bL
+ scode := '';
+ while ((ps^ >= '0') and (ps^ <= '9')) do begin
+ scode := scode + String(ps^);
+ Inc(ps);
+ end;
end;
+ icode := StrToIntDef(scode, 0);
+
+ //\8dÅ\8cã\82ª;\82Å\95Â\82¶\82Ä\82¢\82È\82¯\82ê\82Î\81A\88ê\95¶\8e\9a\91O\82Ü\82Å\82É\82·\82é
+ if not (ps^ = ';') then
+ Dec(ps);
+
+ //\83V\83\8a\83A\8cê\83u\83\89\83N\83\89\82Ì\82Å\82È\82¢
+ if (icode <1792) or (icode > 1871) then
+ Result := Result + Copy(AString, 1, ps - PChar(AString) + 1);
+
+ Delete(AString, 1, ps - PChar(AString) + 1);
end else begin
- tmp := tmp + Copy(AString, 1, 5);
- Delete(AString, 1, 5);
+ //\8cã\82ë\82É\95¶\8e\9a\82ª\96³\82¢\82Ì\82Å\81A\82»\82Ì\82Ü\82ÜResult\82É\93Ë\82Á\8d\9e\82Þ
+ Result := Result + AString;
+ AString := '';
end;
- pos := AnsiPos('³', AString);
+ p := PChar(AString);
+ pe := p + Length(AString);
+ p := AnsiStrPosEx(p, pe, s, se);
end;
- if Length(AString) > 0 then
- tmp := tmp + AString;
- Result := tmp;
+
+ //\8ec\82Á\82½\95¶\8e\9a\97ñ\82ð\91«\82µ\82Ä\8c\8b\89Ê\82É\82·\82é
+ Result := Result + AString;
end;