Сабж нужна помощь в отправке Post запроса Отправляю Post запрос в котором данные указаны в виде русских символов Запрос отправляется в виде крякозябр Пробовал Utf8toAnsi ,меняется только вид крякозябр Как сделать,что бы перекодировались как-то символы и отправлялись в надлежащем виде?
AnsiToUtf8 тоже кракозябры, json формат?*нуб мод он* это какая-то кодировка связанная с JS ? *нуб мод офф* Код: procedure TForm1.Button1Click(Sender: TObject); var PostData:TStringList; html:WideString; begin try PostData:=TStringList.Create; PostData.Clear; PostData.Add('name=123'); PostData.Add('pass=333'); PostData.Add('cap=444'); html:=IdHTTP1.Post('www.site.ru',PostData); PostData.Free; except on e:Exception do PostData.Free; end; end;
Добавь заголовки перед отправлением: Код: IdHTTP1.Request.ContentType:='application/x-www-form-urlencoded'; IdHTTP1.Request.Charset:='utf-8';
Ну на... Код: function EncodeURIComponent(const ASrc: string): UTF8String; const HexMap: UTF8String = '0123456789ABCDEF'; function IsSafeChar(ch: Integer): Boolean; begin if (ch >= 48) and (ch <= 57) then Result := True // 0-9 else if (ch >= 65) and (ch <= 90) then Result := True // A-Z else if (ch >= 97) and (ch <= 122) then Result := True // a-z else if (ch = 33) then Result := True // ! else if (ch >= 39) and (ch <= 42) then Result := True // '()* else if (ch >= 45) and (ch <= 46) then Result := True // -. else if (ch = 95) then Result := True // _ else if (ch = 126) then Result := True // ~ else Result := False; end; var I, J: Integer; ASrcUTF8: UTF8String; begin Result := ''; {Do not Localize} ASrcUTF8 := UTF8Encode(ASrc); // UTF8Encode call not strictly necessary but // prevents implicit conversion warning I := 1; J := 1; SetLength(Result, Length(ASrcUTF8) * 3); // space to %xx encode every byte while I <= Length(ASrcUTF8) do begin if IsSafeChar(Ord(ASrcUTF8[I])) then begin Result[J] := ASrcUTF8[I]; Inc(J); end else if ASrcUTF8[I] = ' ' then begin Result[J] := '+'; Inc(J); end else begin Result[J] := '%'; Result[J+1] := HexMap[(Ord(ASrcUTF8[I]) shr 4) + 1]; Result[J+2] := HexMap[(Ord(ASrcUTF8[I]) and 15) + 1]; Inc(J,3); end; Inc(I); end; SetLength(Result, J-1); end;
Заголовки поставил, как написал? Помогло? Если нет, то резонный вопрос - проверь то, куда отправляешь данные, что там вообще принимается и в каком формате и как ты смотришь, что отправляешь?