我有几个文本框,用户可以将信息输入到他们。这可以包括逗号,所以我不能使用标准的逗号分隔字符串。
I have several textboxes where users can enter information into them. This can include commas, so I can't use the standard comma delimited strings.
什么是一个很好的分隔符来表示字符串应该基于字符ISN分开T通常使用在他们的著作用户?我将这些字段被组合成一个字符串,字符串和鱼目混珠到我的加密方法,我有。当我解密他们,我需要能够可靠地将它们分开。
What is a good delimiter to denote that strings should be separated based on that character that isn't typically used by users in their writings? I'm going to be combining these fields into a string string and passing them off to my Encryption method I have. After I decrypt them I need to be able to reliably separate them.
我使用C#如果它很重要。
I'm using C# if it matters.
推荐答案|下一个会我的名单上,经常被用来作为替代CSV。谷歌管道分隔,你会发现很多的例子。
| would be next on my list and is often used as an alternative to CSV. google "pipe delimited" and you will find many examples.
string[] items = new string[] {"Uno","Dos","Tres"}; string toEncrypt = String.Join("|", items); items = toEncrypt.Split(new char[] {'|'}, StringSplitOptions.RemoveEmptyEntries); foreach(string s in items) Console.WriteLine(s);
既然大家都喜欢要一个关于编码评论家和不提供代码,这里是一个办法文本编码所以你| DELIM不会发生碰撞。
And since everyone likes to be a critic about the encoding and not provide the code, here is one way to encode the text so your | delim won't collide.
string[] items = new string[] {"Uno","Dos","Tres"}; for (int i = 0; i < items.Length; i++) items[i] = Convert.ToBase64String(Encoding.UTF8.GetBytes(items[i])); string toEncrypt = String.Join("|", items); items = toEncrypt.Split(new char[] {'|'}, StringSplitOptions.RemoveEmptyEntries); foreach (string s in items) Console.WriteLine(Encoding.UTF8.GetString(Convert.FromBase64String(s)));更多推荐
什么是一个更独特的分隔符不是逗号分离字符串?
发布评论