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-09 21:01
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Resolved] How to determine whether the input is Chinese or English? View 2,162 Replies 27
Original Poster Posted 2008-09-19 20:03 ·  中国 江西 赣州 安远县 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
RT

[ Last edited by tireless on 2008-9-21 at 04:19 PM ]
Floor 2 Posted 2008-09-19 20:06 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
```batch
@echo off
set/p input=Input:
set str=%input%
:loop
set str=%str:~1%
set/a n+=1
if not "%str%" == "" goto loop
for /f "skip=1 delims=:" %%i in ('^(echo "%input%"^&echo.^)^|findstr /o ".*"') do set/a l=%%i-5
if %n% == %l% (
echo The string %input% does not contain double-byte characters
) else (
echo The string %input% contains double-byte characters
)
pause
```
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
tireless +8 2008-09-21 12:34
Floor 3 Posted 2008-09-19 20:07 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
How to separate Chinese character lines and non-Chinese character lines
http://www.cn-dos.net/forum/viewthread.php?tid=30573
Floor 4 Posted 2008-09-19 20:15 ·  中国 江西 赣州 安远县 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
thx

[ Last edited by tireless on 2008-9-20 at 04:36 PM ]
Floor 5 Posted 2008-09-20 08:51 ·  中国 广东 江门 电信
中级用户
★★
Credits 338
Posts 175
Joined 2007-10-21 15:30
18-year member
UID 100351
Gender Male
Status Offline
Can we use the judgment geq Z?
Floor 6 Posted 2008-09-20 21:09 ·  中国 江西 赣州 安远县 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
Further ask this question, help out ah

Requirement: Calculate the "value" of characters
Chinese characters = 19
English (including spaces) = 10

For example, input 123 一二, then calculate the result of 4*10+2*19
Floor 7 Posted 2008-09-20 22:09 ·  中国 广东 广州 电信
银牌会员
★★★
永远的菜鸟
Credits 1,335
Posts 574
Joined 2007-11-27 12:50
18-year member
UID 103929
Gender Male
From 广西
Status Offline
I wonder if this would work:
@echo off
setlocal enabledelayedexpansion
:bgn
set "n="
set /p str=Please enter:
:agn
set "var=%str:~,1%"
if %var% gtr Z (set /a n+=19) else (set /a n+=10)
if not "%str:~1%"=="" (set "str=%str:~1%"&goto :agn)
echo %n%
goto :bgn
Floor 8 Posted 2008-09-20 22:21 ·  中国 江西 赣州 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
Floor 9 Posted 2008-09-20 22:24 ·  中国 广东 广州 电信
银牌会员
★★★
永远的菜鸟
Credits 1,335
Posts 574
Joined 2007-11-27 12:50
18-year member
UID 103929
Gender Male
From 广西
Status Offline
Originally posted by tireless at 2008-9-20 22:21:
It doesn't work when there are spaces

Does it also need to calculate the value of spaces???
Floor 10 Posted 2008-09-20 22:34 ·  中国 广东 广州 电信
银牌会员
★★★
永远的菜鸟
Credits 1,335
Posts 574
Joined 2007-11-27 12:50
18-year member
UID 103929
Gender Male
From 广西
Status Offline
If you don't count the value of spaces, just remove the spaces...
@echo off
setlocal enabledelayedexpansion
:bgn
set "n="
set /p str=Please enter:
set "str=%str: =%"
set "str=%str: =%"
:agn
set "var=%str:~,1%"
if %var% gtr Z (set /a n+=19) else (set /a n+=10)
if not "%str:~1%"=="" (set "str=%str:~1%"&goto :agn)
echo %n%
goto :bgn
Floor 11 Posted 2008-09-20 22:37 ·  中国 江西 赣州 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
To calculate the value of a space. The value of a space is the same as that of English.
Floor 12 Posted 2008-09-20 23:13 ·  中国 重庆 九龙坡区 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Can the code on floor 7 add double quotes when comparing?
@echo off
setlocal enabledelayedexpansion
:bgn
set "n="
set /p str=Please enter:
:agn
set "var=%str:~,1%"
if "%var%" gtr "Z" (set /a n+=19) else (set /a n+=10)
if not "%str:~1%"=="" (set "str=%str:~1%"&goto :agn)
echo %n%
goto :bgn
Floor 13 Posted 2008-09-20 23:36 ·  中国 广东 韶关 电信
高级用户
★★★
CMD感染者
Credits 691
Posts 383
Joined 2008-05-23 00:38
18-year member
UID 119451
Gender Male
Status Offline
Originally posted by HAT at 2008-9-20 11:13 PM:
Can the code on floor 7 add double quotes during comparison?
@echo off
setlocal enabledelayedexpansion
:bgn
set "n="
set /p str=Please enter:
:agn
set "var=%str:~,1%"
if & ...


It works!
Floor 14 Posted 2008-09-20 23:49 ·  中国 江西 赣州 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
Originally posted by HAT at 2008-9-20 03:13 AM:
Can the code on floor 7 add double quotes when comparing?
@echo off
setlocal enabledelayedexpansion
:bgn
set "n="
set /p str=Please enter:
:agn
set "var=%str:~,1%"
if & ...

Well, the initial test is okay. But when I entered Beds before a bright moon light, I suspect it's frost on the ground. Lifting my head to watch the bright moon, bowing my head to think of home., the calculation result was wrong.
There are a total of 24 characters, and the result should be: 24*19=456
But the calculation result here is 420

Chinese punctuation should be counted as Chinese, right
Floor 15 Posted 2008-09-21 01:30 ·  中国 重庆 九龙坡区 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Then use the idea of the 2nd floor
@echo off
setlocal enabledelayedexpansion
set /p "str=Please enter:"
set sum=0
:loop
set "char=%str:~0,1%"
for /f "skip=1 delims=:" %%a in ('^(echo."%char%"^&echo.^)^|findstr /o ".*"') do set /a len=%%a-5
if %len% equ 1 (
set /a sum+=10
) else if %len% equ 2 (
set /a sum+=19
)
set "str=%str:~1%"
if "%str%" neq "" (
goto :loop
)
:show
echo.%sum%
Forum Jump: