echoing other language texts?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
tcpman
Posts: 53
Joined: 05 Mar 2014 15:01

echoing other language texts?

#1 Post by tcpman » 07 Mar 2015 15:56

is there anyway to echo arabic,persian,russian,Chinese,etc texts in cmd?
(i preform not using external tools)
i serached about this and looks like i have to change the font and chcp but still i cant get the correct output i want!

tnx for your help

Liviu
Expert
Posts: 470
Joined: 13 Jan 2012 21:24

Re: echoing other language texts?

#2 Post by Liviu » 07 Mar 2015 22:02

In XP and earlier it's only possible if you already have an environment variable or a file/directory name containing those characters. In Windows 7 or later it's possible to build such strings in code from scratch, see viewtopic.php?f=3&t=5358 and viewtopic.php?p=34662.

Liviu

OperatorGK
Posts: 66
Joined: 13 Jan 2015 06:55

Re: echoing other language texts?

#3 Post by OperatorGK » 08 Mar 2015 05:04

Use codepages 866 or 1251 to echo text in Russian. I'm from Russia and our default codepage for CMD.EXE is 866. And it's better use hex editor or Notepad++ codepage functions to enter those characters. Example of code:

Code: Select all

@echo off
chcp 866 >nul
echo Привет &rem Russian "Hello"

Open Notepad++, change file codepage to OEM-866 and paste this code. Save it and run. It will produce correct output.

Liviu
Expert
Posts: 470
Joined: 13 Jan 2012 21:24

Re: echoing other language texts?

#4 Post by Liviu » 08 Mar 2015 22:10

@OperatorGK, that works indeed if one only needs characters from one single codepage, such as Cyrillic 866. However, I took OP's question to be about mixing multiple scripts in the same batch, which can't be done via chcp alone - for example, there is no one codepage to cover both Cyrillic and Greek. My answer above applies to that latter case.

OperatorGK
Posts: 66
Joined: 13 Jan 2015 06:55

Re: echoing other language texts?

#5 Post by OperatorGK » 09 Mar 2015 04:35

If so, use cmd /U /C "script.bat". It will turn Unicode on.

Liviu
Expert
Posts: 470
Joined: 13 Jan 2012 21:24

Re: echoing other language texts?

#6 Post by Liviu » 09 Mar 2015 09:06

'cmd /u' does indeed turn "the output of internal commands to a pipe or file" to be Unicode, but it does not affect (or matter for) the console output itself - which was the original question here. The following will work correctly at a plain 'cmd' prompt as long as it's set to use a TT (not raster) font such as Lucida Console, without '/u' and regardless of the active codepage.

Code: Select all

C:\tmp>echo àáâāăąǻ αβγδεζη абвгдеж
àáâāăąǻ αβγδεζη абвгдеж

Post Reply