如何将文本编码为html格式 [英] How to encode text into html format

查看:52
本文介绍了如何将文本编码为html格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想将输入文本编码为html格式,例如replace"<"使用& lt,

替换&用& amp。

你能给我一些想法吗?谢谢。


Fred

Hi,

I want to encode input text into html format such as replace "<" with "&lt",
replace "&" with "&amp".
Could you give me some ideas? Thanks.

Fred


推荐答案

Fred Yu写道:
Fred Yu writes:




我想将输入文本编码为html格式,例如replace"<"" with& lt,
Hi,

I want to encode input text into html format such as replace "<" with "&lt",



那是'& lt;"。

That''s "&lt;".


替换&用& amp表示。
replace "&" with "&amp".



那是'& amp;"。

That''s "&amp;".


你能给我一些吗?想法?谢谢。
Could you give me some ideas? Thanks.



尽量自己做作业。这是一个简单的

搜索/替换操作,有很多方法可以完成它。

----- BEGIN PGP SIGNATURE -----

版本:GnuPG v1.4.9(GNU / Linux)

iEYEABECAAYFAkhC4aQACgkQx9p3GYHlUOJbHQCdFkadJpXTIS tsphfd9cZ1yjhc

4QwAniVg + D // DKToDNz651FJF5MCYIlo

= xhO4

-----结束PGP签名-----

Try to do your homework assignment by yourself. This is a simple
search/replace operation, and there are many ways to get it done.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEABECAAYFAkhC4aQACgkQx9p3GYHlUOJbHQCdFkadJpXTIS tsphfd9cZ1yjhc
4QwAniVg+D//DKToDNz651FJF5MCYIlo
=xhO4
-----END PGP SIGNATURE-----


Fred Yu写道:
Fred Yu wrote:




我想将输入文本编码为html格式,例如replace"<"与

"& lt",替换&&"用& amp。

你能给我一些想法吗?谢谢。
Hi,

I want to encode input text into html format such as replace "<" with
"&lt", replace "&" with "&amp".
Could you give me some ideas? Thanks.



容器:std :: map< char,std :: string>

迭代器:std :: istream_iterator,std :: ostream_iterator

算法:std :: transform

Best


Kai-Uwe Bux


Containers: std::map< char, std::string >
Iterators: std::istream_iterator, std::ostream_iterator
Algorithms: std::transform
Best

Kai-Uwe Bux


6月1日,12:37 * pm,Fred Yu < jean_y_f ... @ sohu.comwrote:
On Jun 1, 12:37*pm, "Fred Yu" <jean_y_f...@sohu.comwrote:




我想将输入文本编码为html格式例如替换<使用& lt,

替换&用& amp。

你能给我一些想法吗?谢谢。


Fred
Hi,

I want to encode input text into html format such as replace "<" with "&lt",
replace "&" with "&amp".
Could you give me some ideas? Thanks.

Fred



google iconv。它会将许多字符编码转换为许多其他字符串编码。\\ b
char

编码。我用它来格式化各种XML包装器中的文本

类。

google iconv. It will convert from many char encodings to many other
char
encodings. I''ve used it to "format" text in various XML wrapper
classes.


这篇关于如何将文本编码为html格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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