![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-14 13:01 |
47,812 topics / 349,917 posts / today 0 new / 48,268 members |
| DOS批处理 & 脚本技术(批处理室) » How to verify whether an input string contains double-byte characters |
| Printable Version 3,296 / 15 |
| Floor1 everest79 | Posted 2008-01-04 20:20 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
As the title says. To expand on that, how can I search for and identify Chinese content in text?
|
|
| Floor2 everest79 | Posted 2008-01-04 20:28 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
I’ve been researching this problem for a year. If you don’t believe me, search for my first post, hehe
|
|
| Floor3 lxmxn | Posted 2008-01-04 20:34 |
| 版主 Posts 4,938 Credits 11,386 | |
|
o_O
Does it have to be pure batch processing? [ Last edited by lxmxn on 2008-1-4 at 08:36 PM ] |
|
| Floor4 zh159 | Posted 2008-01-04 20:45 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
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) input:Chinese input:English input:Chinese+English |
|
| Floor5 zh159 | Posted 2008-01-04 20:56 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
[ Last edited by zh159 on 2008-1-4 at 08:58 PM ] |
|
| Floor6 everest79 | Posted 2008-01-04 21:16 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
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 |
|
| Floor7 HAT | Posted 2008-01-04 21:57 |
| 版主 Posts 5,017 Credits 9,023 | |
|
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: Now there is also the findstr /o method Looking forward to an even simpler method ^_^ |
|
| Floor8 junchen2 | Posted 2008-01-04 23:13 |
| 高级用户 Posts 219 Credits 537 From 杭州--半山 | |
|
echo 望大师,傅.看见fdg|awk "{a=gsub(/[\x80-\xff]/,\"\");print a/2\" Chinese characters\"}"
6 Chinese characters |
|
| Floor9 zh159 | Posted 2008-01-05 00:16 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
Originally posted by everest79 at 2008-1-4 21:16: A VBS script wouldn’t be much simpler either: |
|
| Floor10 lxmxn | Posted 2008-01-05 00:59 |
| 版主 Posts 4,938 Credits 11,386 | |
|
To zh159:
What do you input in this case? :ok我 |
|
| Floor11 zh159 | Posted 2008-01-05 01:11 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
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” |
|
| Floor12 zh159 | Posted 2008-01-05 01:21 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
To determine a string:
|
|
| Floor13 electronixtar | Posted 2008-01-05 17:49 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
| Floor14 zh159 | Posted 2008-01-05 20:17 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
VBS can use regular expressions to determine character types, but I still don’t know how -_-|||
|
|
| Floor15 everest79 | Posted 2008-01-05 20:22 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
Is there a more complete one? I can’t imitate it from just a single line
|
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |