UrlEncode编码 unity c#

今天接入易接的SDK,在支付回调一直失败。问后原因是前端调用易接支付接口pay()中的callbackinfo需要进行urlEncode编码。

为什么需要用urlEncode编码?是因为当字符串数据以url的形式传递给web服务器时,字符串中是不允许出现空格和特殊字符的。

附Unity C#版 urlEncode编码 类

  1 using System.Text;
  2 using System.Collections;
  3 public static class WebUtility
  4 {
  5     // Fields
  6 
  7     private static char[] _htmlEntityEndingChars = new char[] { ';', '&' };
  8     private const char HIGH_SURROGATE_START = '\ud800';
  9     private const char LOW_SURROGATE_END = '\udfff';
 10     private const char LOW_SURROGATE_START = '\udc00';
 11     private const int UNICODE_PLANE00_END = 0xffff;
 12     private const int UNICODE_PLANE01_START = 0x10000;
 13     private const int UNICODE_PLANE16_END = 0x10ffff;
 14     private const int UnicodeReplacementChar = 0xfffd;
 15 
 16 
 17 
 18     private static void ConvertSmpToUtf16(uint smpChar, out char leadingSurrogate, out char trailingSurrogate)
 19     {
 20         int num = ((int) smpChar) - 0x10000;
 21         leadingSurrogate = (char) ((num / 0x400) + 0xd800);
 22         trailingSurrogate = (char) ((num % 0x400) + 0xdc00);
 23     }
 24 
 25     
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值