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

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
V2EX
大猫的无限游戏
大猫的无限游戏
腾讯CDC
博客园 - Franky
WordPress大学
WordPress大学
Jina AI
Jina AI
GbyAI
GbyAI
云风的 BLOG
云风的 BLOG
B
Blog RSS Feed
Last Week in AI
Last Week in AI
The Cloudflare Blog
V
Visual Studio Blog
P
Proofpoint News Feed
博客园 - 叶小钗
L
LangChain Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Recorded Future
Recorded Future
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
Y
Y Combinator Blog
罗磊的独立博客
雷峰网
雷峰网
博客园 - 【当耐特】
Microsoft Security Blog
Microsoft Security Blog
L
LINUX DO - 热门话题
Cisco Talos Blog
Cisco Talos Blog
L
Lohrmann on Cybersecurity
Martin Fowler
Martin Fowler
Spread Privacy
Spread Privacy
MongoDB | Blog
MongoDB | Blog
Engineering at Meta
Engineering at Meta
C
Cybersecurity and Infrastructure Security Agency CISA
小众软件
小众软件
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Recent Announcements
Recent Announcements
T
Threat Research - Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
量子位
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
宝玉的分享
宝玉的分享
D
DataBreaches.Net
T
The Exploit Database - CXSecurity.com
Vercel News
Vercel News
IT之家
IT之家
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
Troy Hunt's Blog
aimingoo的专栏
aimingoo的专栏

博客园 - 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();
        }