delphi unicode 회전gbk

786 단어 delphi

function UniCodetoGBK(S : String):String;
Var
  I,j: Integer;
  str,ps,regmsg: string;
  reg: TPerlRegEx;
begin
  try
    reg := TPerlRegEx.Create(nil);
    regmsg := '\\u[A-Za-z0-9]{4}';
    reg.RegEx := regmsg;
    reg.Subject := s;
    while reg.MatchAgain do
    begin
      ps := reg.MatchedExpression;
      Delete(ps,1,1);
      if (Trim(ps) <> '') and  (Pos('u',ps) = 1) then
      begin
        I := Length(ps);
        while I >=4 do
        begin
          str := WideChar(StrToInt('$'+ps[I-3]+ps[I-2]+ps[I-1]+ps[I]));
          I := I - 4;
        end;
        reg.Replacement := str;
        reg.Replace;
      end;
    end;
    Result := reg.Subject;
    reg.Free;
  except
    reg.Free;
  end;
end;

좋은 웹페이지 즐겨찾기