在文本文件中的每个字母之间放置空格 [英] Putting space between each letter in a text file

查看:87
本文介绍了在文本文件中的每个字母之间放置空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

在一个项目中,我需要修改文本文件的内容.
实际上,我想在每2个相邻字母之间放置一个空格.
为了澄清,假定内容如下:

HelloMahdi313

我想将其更改为:

你好3 1 3

您能帮我摘一下片段吗?

关于

Hello,

In a project I need to modify the contents of a text file.
Actually, I want to put one space between each 2 adjacent letters.
To clarify, assume the contents to be as below:

HelloMahdi313

I want to have it changed to:

H e l l o M a h d i 3 1 3

Could you please help me by getting me a snippet?

Regards

推荐答案

即使对于您来说,放置这些空格也不是问题.如果对某人来说是一个大问题,我建议这个人立即离开这个专业领域.因此,非常欢迎您自己完成此操作,并显示代码并询问是否遇到问题.我们很乐意为您提供帮助.

但是,我想强调指出,解决这样的问题是不好的.在Windows或Mono上使用.NET时,您几乎无法在C#屏幕上正确表示这样的短语.这是因为现代UI会尝试将这些文本包装在意外的位置.

取而代之的是,您需要保留文本的原样,并保留后期间距.例如,对于System.Drawing,在此处进行了讨论: http://stackoverflow.com/questions/2969143/c-drawstring-letter-spacing [ ^ ].

—SA
Putting those blank spaces is not a problem, even for you. If it would be a big problem to someone, I would recommend this person to leave this professional field immediately. Therefore, you''re very welcome to do it by yourself and show your code and ask about your problem if you see one. We would gladly help you.

However, I would like to emphasize that solving such problem is bad thing. You hardly can represent such phrase correctly on the screen C# for using .NET on Windows or Mono. This is because modern UI will try to wrap this text in unexpected place.

Instead, you need to leave the text as is and address latter spacing. For example, for System.Drawing this is discussed here: http://stackoverflow.com/questions/2969143/c-drawstring-letter-spacing[^].

—SA


对我来说,这听起来像是作业,我想不出在现实生活中这样做的合乎逻辑的理由.因此,您可能应该与您的老师交谈.一些提示-您的字符串可以作为字符的集合进入.您可以使用字符串生成器从字符流中构建字符串,也可以在此过程中插入您选择的其他内容.
This sounds like homework to me, I can''t think of a logical reason to do this in real life. As such, you should probably talk to your teacher. Some hints tho - your string can be stepped over as a collection of chars. You can use a string builder to build a string out of a stream of chars, and you could insert something else of your choice along the way.


这篇关于在文本文件中的每个字母之间放置空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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