惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
N
News and Events Feed by Topic
D
DataBreaches.Net
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Engineering at Meta
Engineering at Meta
T
Tailwind CSS Blog
博客园_首页
Microsoft Azure Blog
Microsoft Azure Blog
Y
Y Combinator Blog
博客园 - Franky
Hugging Face - Blog
Hugging Face - Blog
月光博客
月光博客
A
About on SuperTechFans
I
InfoQ
S
Securelist
Last Week in AI
Last Week in AI
S
Schneier on Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
Hacker News: Ask HN
Hacker News: Ask HN
Schneier on Security
Schneier on Security
Know Your Adversary
Know Your Adversary
腾讯CDC
大猫的无限游戏
大猫的无限游戏
S
Security @ Cisco Blogs
博客园 - 三生石上(FineUI控件)
Simon Willison's Weblog
Simon Willison's Weblog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Tor Project blog
美团技术团队
aimingoo的专栏
aimingoo的专栏
G
Google Developers Blog
罗磊的独立博客
Vercel News
Vercel News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
S
Secure Thoughts
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Latest news
Latest news
Recent Announcements
Recent Announcements
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
L
LINUX DO - 热门话题
Security Latest
Security Latest
TaoSecurity Blog
TaoSecurity Blog
Cyberwarzone
Cyberwarzone
有赞技术团队
有赞技术团队

博客园 - skyfei

Xcode 文档注释方法 查看iOS模拟器应用的沙箱文件 Show in Finder OC代码 C# x86应用x64系统上读取x64位应用的注册表 Make webclient support upload the large file which are larger than 1G Shortcut key for WPF get Android information with adb, the build version C# USB Detection - winform and WPF [转] 线程同步 C# 常见面试题(2) 转:C# Interview Questions Openxml: 导出excel 设置 cell的格式 - skyfei OpenXML: excel 插入BarChart图表 OpenXML: Asp.net利用OpenXML 导出Excel. TRIGGERS :Cannot use text, ntext, or image columns in the 'inserted' and ' deleted' tables. 'String or binary data would be truncated' error message .net Create Excel 2007 file with open xml 利用.Net Framework2.0 zip压缩、解压 string 数据 C#中文和UNICODE字符转换方法 - skyfei - 博客园
Decodes a QuotedPrintable encoded string
skyfei · 2010-12-23 · via 博客园 - skyfei

In android vcard file, the QuotedPrintable string will be like:

 ENCODING=QUOTED-PRINTABLE:=E9=A3=9E;=E5=88=98;=E7=A7=8D;=E5=85=88=E7=94=9F;=E5=8F=B7

while in the outlook vcard, it will like:

ENCODING=QUOTED-PRINTABLE:=E5=95=8A=E5=95=8A

that mean that the android will not encode the normail char

so update one decode method, which I find in the internet:

代码

/// <summary>   
        
/// Decodes a QuotedPrintable encoded string    
        
/// 
        
/// </summary>   
        
/// <param name="_ToDecode">The encoded string to decode</param>   
        
/// <returns>Decoded string</returns>   
        public static string DecodeTest(string _ToDecode, string encoderName)
        {
            
//remove soft-linebreaks first   
            
//_ToDecode = _ToDecode.Replace("=\r\n", "");   

            Encoding encoding;
            
if (string.IsNullOrEmpty(encoderName))
            {
                encoding 
= Encoding.Default;
            }
            
else
            {
                
try
                {
                    encoding 
= Encoding.GetEncoding(encoderName);
                   
// encoding = Encoding.Default;
                }
                
catch
                {
                    encoding 
= Encoding.Default;
                }
            }
char[] chars = _ToDecode.ToCharArray();//    byte[] bytes = new byte[chars.Length];
            List<byte> bytes = new List<byte>();
            
int bytesCount = 0;

            StringBuilder sb 

= new StringBuilder();string Hex = string.Empty;
            
bool flag = false;
            
foreach (char c in chars)
            {
                
if (c == '=')
                {
                    flag 
= true;
                }
                
else
                {
                    
if (flag)
                    {
                        Hex 
+= c;
                        
if (Hex.Length == 2)
                        {
                            bytes.Add(System.Convert.ToByte(
int.Parse(Hex, System.Globalization.NumberStyles.HexNumber)));
                            Hex 
= string.Empty;
                            flag 
= false;
                        }
                    }
                    
else
                    {
                        
if (bytes.Count >0)
                        {
                            sb.Append( encoding.GetString(bytes.ToArray(), 
0, bytes.Count));
                            bytes.Clear();
                        }
                        sb.Append(c);
                    }
                }
            }
if (bytes.Count > 0)
            {
                sb.Append(encoding.GetString(bytes.ToArray(), 
0, bytes.Count));
                bytes.Clear();
            }
// original code
            
//for (int i = 0; i < chars.Length; i++)
            
//{
            
//    // if encoded character found decode it   
            
//    if (chars[i] == '=')
            
//    {
            
//        bytes[bytesCount++] = System.Convert.ToByte(int.Parse(chars[i + 1].ToString() + chars[i + 2].ToString(), System.Globalization.NumberStyles.HexNumber));//        i += 2;
            
//    }
            
//    else
            
//    {
            
//        bytes[bytesCount++] = System.Convert.ToByte(chars[i]);
            
//    }
            
//}//return System.Text.Encoding.Default.GetString(bytes, 0, bytesCount);   
            
//return encoding.GetString(bytes, 0, bytesCount);
            return sb.ToString();
        }