普通文本中使用最少的定界符< ASCII 128 [英] Least used delimiter character in normal text < ASCII 128

查看:98
本文介绍了普通文本中使用最少的定界符< ASCII 128的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于编码原因会使您感到恐惧(我很尴尬地说),我需要将多个文本项存储在单个字符串中.

For coding reasons which would horrify you (I'm too embarrassed to say), I need to store a number of text items in a single string.

我将使用字符分隔它们.

I will delimit them using a character.

哪个字符最适合用于此操作,即哪个字符最不可能出现在文本中?必须可打印,并且以ASCII表示可能小于128,以避免区域设置问题.

Which character is best to use for this, i.e. which character is the least likely to appear in the text? Must be printable and probably less than 128 in ASCII to avoid locale issues.

推荐答案

假设出于某些令人尴尬的原因,您无法使用CSV,我想说一下数据.取一些样本数据,并对每个值0-127进行简单的字符计数.选择一种不会发生的情况.如果选择过多,请获取更大的数据集.不需要花费很多时间来编写,并且您会得到最适合自己的答案.

Assuming for some embarrassing reason you can't use CSV I'd say go with the data. Take some sample data, and do a simple character count for each value 0-127. Choose one of the ones which doesn't occur. If there is too much choice get a bigger data set. It won't take much time to write, and you'll get the answer best for you.

对于不同的问题域,答案将有所不同,因此| (pipe)在shell脚本中很常见,^在数学公式中很常见,大多数其他字符也可能如此.

The answer will be different for different problem domains, so | (pipe) is common in shell scripts, ^ is common in math formulae, and the same is probably true for most other characters.

我个人认为我愿意| (管道)(如果可以选择),但处理真实数据是最安全的.

I personally think I'd go for | (pipe) if given a choice but going with real data is safest.

无论您做什么,请确保已制定出逃避方案!

And whatever you do, make sure you've worked out an escaping scheme!

这篇关于普通文本中使用最少的定界符< ASCII 128的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆