- pos: Integer;
- tmp: string;
-begin
- pos := AnsiPos('', AString);
- while pos <> 0 do begin
- if StrToIntDef(Copy(AString, pos+4, 2), -1) > 0 then begin
- if (AString[pos+6] = ';' ) or (AString[pos+6] = ' ') then begin
- tmp := tmp + Copy(AString, 1, pos - 1);
- Delete(AString, 1, pos+6);
- end else if StrToIntDef(AString[pos+6], -1) = -1 then begin
- tmp := tmp + Copy(AString, 1, pos - 1);
- Delete(AString, 1, pos+5);
- end else begin
- tmp := tmp + Copy(AString, 1, pos + 5);
- Delete(AString, 1, pos+5);
- end;
- end else begin
- tmp := tmp + Copy(AString, 1, pos + 5);
- Delete(AString, 1, pos+5);
- end;
- pos := AnsiPos('', AString);
- end;
- if Length(AString) > 0 then
- tmp := tmp + AString;
- AString := tmp;
- tmp := '';
-
- pos := AnsiPos('³', AString);
- while pos <> 0 do begin
- if StrToIntDef(Copy(AString, pos+5, 1), 0) > 2 then begin
- if (AString[pos+6] = ';') or (AString[pos+6] = ' ') then begin
- tmp := tmp + Copy(AString, 1, pos - 1);
- Delete(AString, 1, pos+6);
- end else if StrToIntDef(AString[pos+6], -1) = -1 then begin
- tmp := tmp + Copy(AString, 1, pos - 1);
- Delete(AString, 1, pos+5);
+ 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;