Zhaojun WU wrote:
Hi, Tony,
Thanks for you reply.
I've already tried the xxd solution, but it converts all of the
characters into hex values, it is hard to locate a particular
character's value. It might be possible to copy this character out to
a new window and use ":%!xxd" to check its hex value, but it takes two
steps with an additional window. It is acceptable but a little bit
inconvenient.
(Is there any shortcut (i mean key-combination or function) for these
steps?)
[...]
As long as 'encoding' is set to UTF-8, there is no easy way to get the cp936
value of a given character in the buffer. It would be possible to write the
character to a cp936-encoded file and convert that to hex; once the required
function or command has been written in vimscript, you can map them to a key.
I'm not trying, but here are the steps I can think of:
1) (This is the big one) Write a function to create a file (probably with the
help of "tempname()") containing a string (given as parameter) in a given
'fileencoding' (given as another parameter), apply xxd to that file, and
":echo" the result (using ":echo system(xxd tempfilename)". Conversion
failures should be handled somehow.
2) (optional) Write a command or commands to invoke that function.
3) Map the invocation to a key.
Best regards,
Tony.
--
There were in this country two very large monopolies. The larger of
the two had the following record: the Vietnam War, Watergate, double-
digit inflation, fuel and energy shortages, bankrupt airlines, and the
8-cent postcard. The second was responsible for such things as the
transistor, the solar cell, lasers, synthetic crystals, high fidelity
stereo recording, sound motion pictures, radio astronomy, negative
feedback, magnetic tape, magnetic "bubbles", electronic switching
systems, microwave radio and TV relay systems, information theory, the
first electrical digital computer, and the first communications
satellite. Guess which one got to tell the other how to run the
telephone business?