OSDN Git Service

remodelingブランチから、最新版をマージ
[gikonavigoeson/gikonavi.git] / MojuUtils.pas
index 3c11cf8..22ce9b0 100644 (file)
@@ -21,26 +21,27 @@ uses
        function ReplaceString(const S, OldPattern, NewPattern: string): string;
        function IgnoCaseReplaceString(const S, OldPattern, NewPattern: string): string;
 
-       function CustomStringReplace(S , OldPattern: String;const  NewPattern: string): String; overload;
-       function CustomStringReplace(S , OldPattern: String;const  NewPattern: string; IgnoreCase : Boolean): String; overload;
-       procedure CustomStringReplace(var S : TStringList; OldPattern: String;const  NewPattern: string);overload;
-       procedure CustomStringReplace(var S : TStringList; OldPattern: String;const  NewPattern: string; IgnoreCase : Boolean);overload;
+       function CustomStringReplace(S , OldPattern: String;const  NewPattern: string; IgnoreCase : Boolean = False): String; overload;
+       procedure CustomStringReplace(var S : TStringList; OldPattern: String;const  NewPattern: string; IgnoreCase : Boolean = False); overload;
 
        function ZenToHan(const s: string): string;
        function VaguePos(const Substr, S: string): Integer;
 
-    function ReplaseNoValidateChar( inVal : String): String;
-    function IsNoValidID( inID :String): Boolean;
+       function ReplaseNoValidateChar( inVal : String): String;
+       function IsNoValidID( inID :String): Boolean;
+       //<font>\83^\83O\82ð\91S\82Ä\8dí\8f\9c\82·\82é
+       function        DeleteFontTag( inSource : string) : string;
+
 implementation
 // \83|\83C\83\93\83^\81[\81\95\83A\83Z\83\93\83u\83\89\82É\82æ\82é\8d\82\91¬\83|\83X
 function StrPosEx(StrStart, StrEnd, SubstrStart, SubstrEnd: PChar): PChar;
 asm
-        PUSH    EBX
+               PUSH    EBX
                PUSH    ESI
-        PUSH    EDI
+               PUSH    EDI
 
-        MOV    ESI,ECX        { Point ESI to substr                  }
-        MOV    EDI,EAX        { Point EDI to s                        }
+               MOV    ESI,ECX        { Point ESI to substr                  }
+               MOV    EDI,EAX        { Point EDI to s                        }
 
         MOV    ECX,EDX        { ECX = search length                  }
         SUB    ECX,EAX
@@ -120,19 +121,19 @@ var
 begin
     Result := S;
     if OldPattern = '' then Exit;
-    p := PChar(S);
-    e := p + Length(S);
-    ps := PChar(OldPattern);
-    pe := ps + Length(OldPattern);
-    ReplaceCount := 0;
-    while p < e do begin
-        p := AnsiStrPosEx(p, e, ps, pe);
-        if p = nil then Break;
-        Inc(ReplaceCount);
-        Inc(p, Length(OldPattern));
-    end;
-    if ReplaceCount = 0 then Exit;
-    SetString(Result, nil, Length(S) +
+       p := PChar(S);
+       e := p + Length(S);
+       ps := PChar(OldPattern);
+       pe := ps + Length(OldPattern);
+       ReplaceCount := 0;
+       while p < e do begin
+               p := AnsiStrPosEx(p, e, ps, pe);
+               if p = nil then Break;
+               Inc(ReplaceCount);
+               Inc(p, Length(OldPattern));
+       end;
+       if ReplaceCount = 0 then Exit;
+       SetString(Result, nil, Length(S) +
     (Length(NewPattern) - Length(OldPattern)) * ReplaceCount);
     p := PChar(S);
     DestIndex := 1;
@@ -204,16 +205,6 @@ end;
 {$R+}
 {$ENDIF}
 
-//\8d\82\91¬\95\8e\9a\97ñ\92u\8a·\8aÖ\90\94\81i\83v\83\8a\83~\83e\83B\83u\81j
-function CustomStringReplace(
-       S ,OldPattern: String;
-       const NewPattern: string
-): String;
-
-begin
-       Result := ReplaceString(S,OldPattern,NewPattern);
-end;
-
 //\8d\82\91¬\95\8e\9a\97ñ\92u\8a·\8aÖ\90\94\81i\94Ä\97p\94Å\82P\81j
 function CustomStringReplace(
        S , OldPattern: String;
@@ -252,22 +243,6 @@ begin
        S.EndUpdate;
 end;
 
-//\8d\82\91¬\95\8e\9a\97ñ\92u\8a·\8aÖ\90\94\81i\94Ä\97p\94Å\82R\81j
-procedure CustomStringReplace(
-       var S : TStringList;
-       OldPattern: String;
-       const  NewPattern: string
-);
-var
-       i : Integer;
-begin
-       S.BeginUpdate;
-       for i := 0 to S.Count - 1 do begin
-               S.Strings[i] := ReplaceString(S.Strings[i], OldPattern,NewPattern);;
-       end;
-       S.EndUpdate;
-end;
-
 (*************************************************************************
  * \91S\8ap\81¨\94¼\8ap
  * from HotZonu
@@ -306,23 +281,56 @@ begin
        Result := CustomStringReplace(inVal, '\', '\81\8f');
     Result := CustomStringReplace(Result, '/', '\81^');
        Result := CustomStringReplace(Result, '*', '\81\96');
-    Result := CustomStringReplace(Result, '>', '\81\84');
-    Result := CustomStringReplace(Result, '<', '\81\83');
-    Result := CustomStringReplace(Result, '|', '\81b');
+       Result := CustomStringReplace(Result, '>', '\81\84');
+       Result := CustomStringReplace(Result, '<', '\81\83');
+       Result := CustomStringReplace(Result, '|', '\81b');
 end;
 (*************************************************************************
  * \96³\8cø\82ÈID\82©\82Ì\83`\83F\83b\83N\81i\96³\8cø\97á\81FID:??? , ID:???0)
  *************************************************************************)
 function IsNoValidID( inID :String): Boolean;
 begin
-    inID := Trim(inID);
-    if inID = '' then Result := True
-    else begin
-       inID := Copy(inID, AnsiPos(':', inID) + 1, Length(inID) );
-        inID := CustomStringReplace(inID, '?', '');
-        if (inID = '') or (inID = '0') then Result := True
-        else Result := False;
-    end;
+       inID := Trim(inID);
+       if inID = '' then Result := True
+       else begin
+               inID := Copy(inID, AnsiPos(':', inID) + 1, Length(inID) );
+               inID := CustomStringReplace(inID, '?', '');
+               if (inID = '') or (inID = '0') then Result := True
+               else Result := False;
+       end;
+end;
+
+// *************************************************************************
+// HTML\92\86\82Ì<font>\83^\83O\82ð\8dí\8f\9c\82·\82é
+// *************************************************************************
+function       DeleteFontTag(
+        inSource : string    //\83^\83O\82ð\8dí\8f\9c\82·\82é\95\8e\9a\97ñ
+) : string;            //\83^\83O\8dí\8f\9c\8cê\82Ì\95\8e\9a\97ñ
+var
+       pos : Integer;
+begin
+       Result := '';
+
+       //</font>\82ð\8dí\8f\9c
+       inSource := CustomStringReplace( inSource, '</font>', '', True);
+       //<font \82ð\91S\82Ä\8f¬\95\8e\9a\82É\95Ï\8a·\82·\82é
+       inSource := CustomStringReplace( inSource, '<font', '<font', True);
+       //<font \81\82ð\8dí\8f\9c\82·\82é
+       pos := AnsiPos('<font', inSource);
+       while (pos > 0) do begin
+               Result := Result + Copy(inSource, 1, pos - 1);
+               Delete(inSource, 1, pos);
+               //\83^\83O\82ð\95Â\82\82é'>'\82Ü\82Å\82ð\8dí\8f\9c
+        pos := AnsiPos('>', inSource);
+               Delete(inSource, 1, pos);
+               pos := AnsiPos('<font', inSource);
+       end;
+
+       Result := Result + inSource;
+
+
 end;
+// *************************************************************************
+
 
 end.