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!
Credits 3,687 Posts 1,467 Joined 2005-08-08 12:00 20-year member UID 44210
Status Offline
First use character substring extraction to get a single character, then use your (echo string&echo.)|findstr /o ".*" to determine whether it is two bytes
(use character substring extraction to determine the number of characters, then use (echo string&echo.)|findstr /o ".*" to determine the number of bytes; if they are equal, then it does not contain double-byte characters)
Credits 2,564 Posts 1,127 Joined 2006-12-25 22:57 19-year member UID 74552 Gender Male
Status Offline
zh159
Hehe, I also only discovered findstr's o parameter while researching this, but this makes the code a bit too long, so I wanted to ask whether there’s any other method
lxmxn
A somewhat simpler VBS script would also be fine
Credits 9,023 Posts 5,017 Joined 2007-05-31 19:39 19-year member UID 89899 Gender Male
Status Offline
A long time ago a moderator taught us a method:
After reading the first character, first use batch processing to determine whether it is a space. If it is not a space, then use:
echo %x%>3.txt and then check whether the file size of 3.txt is one byte or two bytes to determine whether it is a Chinese character.
Credits 3,687 Posts 1,467 Joined 2005-08-08 12:00 20-year member UID 44210
Status Offline
Originally posted by everest79 at 2008-1-4 21:16:
zh159
Hehe, I also only discovered findstr's o parameter while researching this, but this makes the code a bit too long, so I wanted to ask whether there’s any other method
lxmxn
A somewhat simpler VBS script would also be fine
for /f %%i in ('"cscript //nologo ascw.vbs %input%"') do (
if %%i leq 255 (
echo %input% is not a double-byte character
) else (
echo %input% is a double-byte character
)
)
pause
Recent Ratings for This Post
( 1 in total)Click for details
Credits 3,687 Posts 1,467 Joined 2005-08-08 12:00 20-year member UID 44210
Status Offline
ascw can only process characters one by one; to determine a whole sentence you need other statements to work with it
So in my post #9 I only wrote “is not a double-byte character / is a double-byte character”, and not “contains or does not contain double-byte characters”