Results 1 to 4 of 4
Hi All,
I'm having a little difficulty with char sets. Anyway I have generated this XML file, but it contains the following chars which is blowing the parser:
~R ~V ...
- 04-21-2008 #1
How to enter special Chars in VI ~R ~V
Hi All,
I'm having a little difficulty with char sets. Anyway I have generated this XML file, but it contains the following chars which is blowing the parser:
- ~R
- ~V
- ^M
Now I know how to enter the ^M by entering <ctrl v><ctrl m>. Can anyone let me know how I actually enter the other chars into vi?
Basically like the ^M I want to remove them using %s/~R//g
Any suggestions appreciated.
Thanks
- 04-23-2008 #2Just Joined!
- Join Date
- Apr 2008
- Posts
- 35
Hey There,
For the tilde (~) in vi, you just need to backslash on your match like
%s/\~R//g
to get rid of that.
Best wishes
, Mike
- 07-29-2008 #3Just Joined!
- Join Date
- Aug 2006
- Posts
- 6
Anyone know an answer to this? I"m have the exact same problem. The ~R is a special character, just like ^M, so its cannot be found using from (from the several ways I've tried at least). Doing :%s/\~R//g does not work for the same reason it wouldn't work when searching for ^M -- they are special (blue) characters.
I've tried converting the document with dos2unix - only gets rid of ^M's, not ~R.
Tried grep and perl searches, they cannot find the ~R.
Tried converting the document to hex with od -x, still didn't find it.
If anyone knows of a way to search and replace these things, I will be very grateful! I have ~4k xml files that have this issue.
Thanks!
- 07-29-2008 #4Just Joined!
- Join Date
- Aug 2006
- Posts
- 6
Solved this FYI.
~R in hex is 0x96, I found that out by putting my cursor over it in vim, and the status bar of vim reads out the characters byte value. I then wrote a quick perl script to find and replace all of them (along with 0x92 which I believe are the ^V characters).
#!/usr/bin/env bash
# Deletes all invalid characters in XML reports. To find out what the hex value is
# open the file in vim and it'll say something like bytval=0x92, take the last two numbers
# and add them to the regex below.
# www.wikitechie.org
for i in `ls *.xml`; do perl -pi -e "s/(\x92)|(\x96)//g" "$i" ; done


Reply With Quote
