首页 Delphi传中文参数给Jsp

Delphi传中文参数给Jsp

举报
开通vip

Delphi传中文参数给JspDelphi传中文参数给Jsp delphi: function URLEncode(const S: string; const InQueryString: Boolean): string; var Idx: Integer; // loops thru characters in string begin Result := ''; for Idx := 1 to Length(S) do begin case S[Idx] of 'A'..'Z', 'a'..'z', '0'..'9',...

Delphi传中文参数给Jsp
Delphi传中文参数给Jsp delphi: function URLEncode(const S: string; const InQueryString: Boolean): string; var Idx: Integer; // loops thru characters in string begin Result := ''; for Idx := 1 to Length(S) do begin case S[Idx] of 'A'..'Z', 'a'..'z', '0'..'9', '-', '_', '.': Result := Result + S[Idx]; ' ': if InQueryString then Result := Result + '+' else Result := Result + '%20'; else Result := Result + '%' + SysUtils.IntToHex(Ord(S[Idx]), 2); end; end; end; showmessage(URLEncode( UTF8Encode( '李世学'), True)); java: request.setCharacterEncoding( utf-8 ); String errorMessage=request.getParameter( errorMessage ); 附: jsp url传递中文参数 均按utf-8编码 %@ page contentType= text/html; charset=utf-8 发送页面 str=java.net.URLEncoder.encode(str, UTF-8 ); response.sendRedirect( error.jsp?errorMessage= +str); 接收页面 request.setCharacterEncoding( utf-8 ); String errorMessage=request.getParameter( errorMessage ); delphi 最快速编码 URLDecode URLEncode function URLDecode(const S: string): string; var Idx: Integer; // loops thru chars in string Hex: string; // string of hex characters Code: Integer; // hex character code (-1 on error) begin // Intialise result and string index Result := ''; Idx := 1; // Loop thru string decoding each character while Idx = Length(S) do begin case S[Idx] of '%': begin // % should be followed by two hex digits - exception otherwise if Idx = Length(S) - 2 then begin // there are sufficient digits - try to decode hex digits Hex := S[Idx+1] + S[Idx+2]; Code := SysUtils.StrToIntDef('$' + Hex, -1); Inc(Idx, 2); end else // insufficient digits - error Code := -1; // check for error and raise exception if found if Code = -1 then raise SysUtils.EConvertError.Create( 'Invalid hex digit in URL' ); // decoded OK - add character to result Result := Result + Chr(Code); end; '+': // + is decoded as a space Result := Result + ' ' else // All other characters pass thru unchanged Result := Result + S[Idx]; end; Inc(Idx); end; end; function URLEncode(const S: string; const InQueryString: Boolean): string; var Idx: Integer; // loops thru characters in string begin Result := ''; for Idx := 1 to Length(S) do begin case S[Idx] of 'A'..'Z', 'a'..'z', '0'..'9', '-', '_', '.': Result := Result + S[Idx]; ' ': if InQueryString then Result := Result + '+' else Result := Result + '%20'; else Result := Result + '%' + SysUtils.IntToHex(Ord(S[Idx]), 2); end; end; end;
本文档为【Delphi传中文参数给Jsp】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_713593
暂无简介~
格式:doc
大小:17KB
软件:Word
页数:4
分类:生活休闲
上传时间:2018-02-20
浏览量:11