OSDN Git Service

This commit was manufactured by cvs2svn to create branch 'Bb62'.
[gikonavigoeson/gikonavi.git] / MojuUtils.pas
index 71fbd9c..4c87fb0 100644 (file)
@@ -103,10 +103,10 @@ begin
     Result := StrPosEx(StrStart, StrEnd, SubstrStart, SubstrEnd);
 
     while (Result <> nil) and (StrEnd - Result >= L2) do begin
-       ByteType := StrByteType(StrStart, Integer(Result-StrStart));
-       if (ByteType <> mbTrailByte) and
-               (CompareString(LOCALE_USER_DEFAULT, SORT_STRINGSORT, Result, L2, SubstrStart, L2) = 2)
-       then Exit;
+               ByteType := StrByteType(StrStart, Integer(Result-StrStart));
+               if (ByteType <> mbTrailByte) and
+                       (CompareString(LOCALE_USER_DEFAULT, SORT_STRINGSORT, Result, L2, SubstrStart, L2) = 2)
+               then Exit;
        if (ByteType = mbLeadByte) then Inc(Result);
        Inc(Result);
        Result := StrPosEx(Result, StrEnd, SubStrStart, SubStrEnd);
@@ -289,17 +289,26 @@ begin
        Result := CustomStringReplace(Result, '|', '\81b');
 end;
 (*************************************************************************
- * \96³\8cø\82ÈID\82©\82Ì\83`\83F\83b\83N\81i\96³\8cø\97á\81FID:??? , ID:???0)
+ * \96³\8cø\82ÈID\82©\82Ì\83`\83F\83b\83N\81i\96³\8cø\97á\81FID:??? , ID:???X)
  *************************************************************************)
 function IsNoValidID( inID :String): Boolean;
+var
+    bTail : Boolean;
 begin
+    Result := True;
        inID := Trim(inID);
-       if inID = '' then Result := True
-       else begin
+       if (Length(inID) > 0) then begin
                inID := Copy(inID, AnsiPos(':', inID) + 1, Length(inID) );
+        bTail := False;
+        // \96\96\94ö\82ª?\88È\8aO\82©
+        if Length(inID) > 0 then begin
+            bTail := (inID[Length(inID)] <> '?');
+        end;
                inID := CustomStringReplace(inID, '?', '');
-               if (inID = '') or (inID = '0') then Result := True
-               else Result := False;
+               if (Length(inID) > 0) and (not
+            ((Length(inID) = 1) and (bTail))) then begin
+                   Result := False;
+        end;
        end;
 end;
 
@@ -352,23 +361,31 @@ begin
        pds := PChar(delimiter);
        pde := pds + Length(delimiter);
 
-       pos := AnsiStrPosEx(pss, pse, pds, pde);
+       pos := StrPosEx(pss, pse, pds, pde);
        if pos <> nil then begin
                p := pos - pss;
                SetString(Result, pss, p);
                Delete(s, 1, p + Length(delimiter));
+        if (Length(Result) > 0) then begin
+               if (StrByteType(PChar(Result), Length(Result)-1) = mbLeadByte) then begin
+                       SetLength(Result, Length(Result) - 1);
+                   end;
+        end;
        end else begin
                Result := s;
                s := '';
        end;
 end;
-//! \96³\8aQ\89»(& -> &amp; " -> &auot; \82É\95Ï\8a·\82·\82é)
+
+//! \96³\8aQ\89»(& -> &amp; " -> &quot; \82É\95Ï\8a·\82·\82é)
 function Sanitize(const s: String): String;
 begin
-       Result := CustomStringReplace(s, '&', '&amp;');
+    // \97]\95ª\82É\83T\83j\83^\83C\83Y\82³\82ê\82È\82¢\82æ\82¤\82É\82¢\82Á\82½\82ñ\8c³\82É\96ß\82·
+    Result := UnSanitize(s);
+       Result := CustomStringReplace(Result, '&', '&amp;');
        Result := CustomStringReplace(Result, '"', '&quot;');
 end;
-//! \96³\8aQ\89»\89ð\8f\9c(&amp; -> & &auot; -> " \82É\95Ï\8a·\82·\82é)
+//! \96³\8aQ\89»\89ð\8f\9c(&amp; -> & &quot; -> " \82É\95Ï\8a·\82·\82é)
 function UnSanitize(const s: String): String;
 begin
        Result := CustomStringReplace(s, '&quot;', '"');