Hindi string not supported as an input - python-2.7

I am new to python programming.I want to give Hindi string as an input to a variable in python as:
a='शिक्षा का अधिकार अधिनियम'
On writing this on command prompt I get an error message as
'Unsupported characters in input'
I am using Python 2.7 on windows.Can anyone suggest how to get rid of this problem

Related

How to use VSCode to watch a Chinese string in C++?

I want to debug a C++ program in VS code. However, when I watch a variable which is a Chinese string, it displays a series of Unicode characters. How can I get the correct Chinese value of this variable?
The problem is caused by the system charset in docker. The default charset en_US.UTF-8 doesn't support Chinese. When I set the charset to C.utf8, now the VS Code can display Chinese string correctly.
LANG=C.utf-8
source /etc/profile

How to Capture control codes in pexpect python module

I am running some commands in pexpect session where it gives the following output in console.
this is the first line output
\u0000>\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000
I am having a regex '\r\n>' to match the prompt '>' at the new line.
From the output I can see there is one control character \u0000 is prefixed before the prompt comes
\u0000>\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000
My code goes like
child = pexpect.spawn('/bin/bash')
child.sendline(command)
child.expect('\r\n>')
Because of this control character prefixed before the prompt, the expect is failing. Is there any way to solve this issue.
Logically we can see the prompt came in next line, but literally how we can match along with control character?
Do i need to modify my regex to match "controlchar\r\n>"? or any other way to solve this issue?

Using Squish with python, where the text of a print is printed?

In a python script that is called by the test case, I writed a print.
Where the output of a the function print is printed ?
Note : I use Squish 6.2.0 with python 2.7, but any answer to the question will be welcome.
To see the text printed by the python print, click on 'Show View', then 'Runner/Server Log'.

Using French text in Python script

I am new to Python, and I am trying to change some text from English to French in a series of ArcGIS maps, using a Python script (running version 2.7.12) and editing it in IDLE. Following the suggestions in these posts
Write french characters in python 2.7
How to make the python interpreter correctly handle non-ASCII characters in string operations?
I used
#!/usr/bin/python2.7
# coding: utf-8
as the first lines of my script, and included a 'u' inside the brackets before the text with the French character. However, when I make the substitution, I can no longer save or run the script.
The following code generates the English text correctly:
if name[0] == "Alcids":
elm_spp.text = '\r\n'.join(textwrap.wrap("Alcids: ANMU, CAAU, COMU, MAMU,
PIGU, RHAU, UNAL",30))
The following does not allow me to save or run the script:
if name[0] == "Alcids":
elm_spp.text = '\r\n'.join(textwrap.wrap(u"Alcidés: GUCB, SCAS, GUMA,
GMRB, GUCO, MARH, ALSP",30))
Can anyone tell me what I am missing?
Thanks.

Why does termcolor not work in python27 windows?

I just installed termcolor for python 2.7 on windows8.1. When I try to print colored text, I get the strange output.
from termcolor import colored
print colored('Hello world','red')
Here is the result:
[31mHello world[0m
Help to get out from this problem.Thanks,In advance
See this stackOverflow post.
It basically says that in order to get the escape sequences working in Windows, you need to run os.system('color') first.
For example:
import termcolor
import os
os.system('color')
print(termcolor.colored("Stack Overflow", "green")
termcolor or colored works perfectly fine under python 2.7 and I can't replicate your error on my Mac/Linux.
If you looks into the source code of colored, it basically print the string in the format as
\033[%dm%s\033[0m' % (COLORS[color], text)
Somehow your terminal environment does not recognise the non-printing escape sequences that is used in the unix/linux system for setting the foreground color of xterm.