什么是一个更独特的分隔符不是逗号分离字符串?

编程入门 行业动态 更新时间:2024-10-25 14:25:17
本文介绍了什么是一个更独特的分隔符不是逗号分离字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有几个文本框,用户可以将信息输入到他们。这可以包括逗号,所以我不能使用标准的逗号分隔字符串。

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)));

更多推荐

什么是一个更独特的分隔符不是逗号分离字符串?

本文发布于:2023-10-16 10:21:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1497294.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:是一个   逗号   字符串   独特   分隔符

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!