China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-11 06:17
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How to replace the character "%40" in text View 958 Replies 10
Original Poster Posted 2009-01-27 01:20 ·  中国 北京 丰台区 联通
新手上路
Credits 3
Posts 3
Joined 2008-12-20 22:03
17-year member
UID 134478
Gender Male
Status Offline
I have a text file where, for some reason, the decoding was incomplete, so many symbols were not decoded.
I need to replace them manually:

%2A replace with *
%40 replace with @
%2B replace with+
%2C replace with,
In short, all those HTML special character encodings need to be replaced with their corresponding symbols.
There are a whole series of replacements like this, which is very cumbersome.
I came to your forum because of its reputation, hoping to find a solution. Please give me some help, and thanks in advance.
Floor 2 Posted 2009-01-27 01:41 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Keyword: ASCII

I suggest using some third-party software to handle it.
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore
Floor 3 Posted 2009-01-27 15:21 ·  中国 北京 丰台区 联通
新手上路
Credits 3
Posts 3
Joined 2008-12-20 22:03
17-year member
UID 134478
Gender Male
Status Offline
Can you help me solve this problem? Or give me a piece of code
Floor 4 Posted 2009-01-27 15:30 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
bat can't do it; if encoding is supported, the simplest way is to use vbs.

Could you provide a sample text, that is, a snippet from your text?
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore
Floor 5 Posted 2009-01-27 15:53 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
If you use the text replacement tool fr,
http://baiy.cn/utils/fr/index.htm

fr test.txt -fic:"%%2A" -t:"*"
fr test.txt -fic:"%%40" -t:"@"
.......

[ Last edited by yishanju on 2009-1-27 at 16:07 ]

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 6 Posted 2009-01-27 17:08 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
How many lines would have to be written like this =。= There are usually 86 characters...
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore
Floor 7 Posted 2009-01-27 17:18 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
If you use vim, you can use the following to get it done:
:%s/%\(\x\{2}\)/\=nr2char("0x".submatch(1))/g
Floor 8 Posted 2009-01-27 18:08 ·  中国 广东 江门 电信
中级用户
★★
Credits 338
Posts 175
Joined 2007-10-21 15:30
18-year member
UID 100351
Gender Male
Status Offline
Powerful vim replacement.
Floor 9 Posted 2009-01-27 23:29 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
Originally posted by slore at 2009-1-27 17:08:
How many lines would have to be written like this =。= There are usually 86 characters...


-_- My skills are limited,,,, that's the only way I know
If there were a list matching encoded characters to their equivalents, that would be a bit better

[ Last edited by yishanju on 2009-1-27 at 23:44 ]

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 10 Posted 2009-01-27 23:41 ·  中国 北京 丰台区 联通
新手上路
Credits 3
Posts 3
Joined 2008-12-20 22:03
17-year member
UID 134478
Gender Male
Status Offline
Originally posted by slore at 2009-1-27 15:30:
bat can't do it; if encoding is supported, the simplest way is to use vbs.

Could you provide a sample text, that is, a snippet from your text?


Thanks, brother. With the software you provided, I achieved my goal. Many thanks!
Floor 11 Posted 2009-01-28 00:10 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore
Forum Jump: