What is this for a character `\ x9d`? - text

While parsing a text file and doing some prints for debug purposes, the print stucks at a point but I didn't get any errors and the script seemed be running further. So I checked the file content and I recognised a rectangle character. I copied it to the python interpreter and the interpreter got stuck as well.
I checked on Unicode Lookup the character definition: osc operating system command and the unicode is \x9d. What does that mean?🤔
This is the character how it looks here:
Edit: After posting I recognised, that the character is invisible. So I did a screenshot from the editing view, so you see the character from the edit mode perspective.

Related

Python ANSI Color Codes

Python 3.7, on Windows print does not work as expected for ANSI color codes until shell=True once in subprocess.call().
In the below links it appears to imply that the ANSI color codes should work using the "print" command out of the box.
How to print colour/color in python?
Print in terminal with colors using Python?
the second one mentions VT100 emulation... not sure what exactly that means. I am able to write a batch file that outputs the color fine so I would think (naively) that it should work the same way in Python.
However I am not able to use the ANSI color codes as it seems that the ESC character is being "commented out"(?) because for instance when I
print(u"\u001b[31mHelloWorld")
I am not able to see the colored output, as the ESC character seems to be necessary in Windows and prints in the python shell as "[?]" (a box with a question mark)
Is there something I am missing here?
I found myself an answer. As often happens I just did not look far enough.
the Colorama module can be installed with
py -m pip install colorama
and comes with a method definition at the root of the module called init
colorama.init()
This is a cross platform function in that it is only useful on windows (it saves the active Terminal state for reversal and writes the Terminal to preprocess ANSI codes), it does nothing for other operating systems.
I am thinking about implementing an even more lightweight solution using ctypes and setting the Interpret flags on the active terminal myself.
If you are interested in more information, see here:
https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
Output Sequences
The following terminal sequences are intercepted by the console host when written into the output stream, if the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag is set on the screen buffer handle using the SetConsoleMode flag. Note that the DISABLE_NEWLINE_AUTO_RETURN flag may also be useful in emulating the cursor positioning and scrolling behavior of other terminal emulators in relation to characters written to the final column in any row.
Emphasis mine.

python console does not display ü

dear fellow developers,
I have tried to teach python console to display ü, but it insists with displaying ü instead. I have tried it with Python 3.5 and Python 3.6. The result is the same. If I run a .py file containing line print("ü") with F5 command, it displays
ü
instead of ü. If I type in the console
print ("ü")
it displays
ü
I know it has been discussed many times, but most of the methods I have come across during the last 5 hours have not helped me or I have not applied them properly. The problem exists also with other non ascii characters. I appreciate your help!
Try adding the following line on the top on your source file : # coding: utf-8
Also, check if your file encoding is correct (Always choose UTF-8).

filetype and corresponding program that will honor control characters

I am using Node.js to write to log files, using the colors module which I believe inserts control characters into strings, for coloring/text formatting which will display in a terminal application.
When I write to the terminal directly, it shows colors, but when I write to a .log file and then tail the log file with either Terminal.app or iterm2, it does not show colors/text formatting. Does anybody know why this is? My guess is that when you write to the log file the control characters don't get saved? In that way, when tailing they won't display at all?
Perhaps if I write to .txt file or some other type of file, the control characters will remain?
How does this work exactly? At some point the control characters are getting stripped or ignored and I am not sure how or when.
See this code.
It checks if the output is going to a terminal (by checking process.stdout.isTTY) or to somewhere else, like a file. If the latter, no color codes are outputted.

how to detect/ remove 'UTF-8' code in python (window 10 console )

saw some answers on this but not really useful
I do some coding with python using blender 2.6
and on occasion I copy text from internet page or from Libre office text document
so there might be some control characters UTF-8 copied to the text editor for python in blender
problem is I cannot detect where UTF-8 characters are located in blender text editor or even using outside text editor like notepad 2 or notepad ++
so my question is there a simple way to detect and remove these UNTF-8 characters ?
I mean on window 10 in blender using some python commands or using external text editor!
I need something quick or a simple trick here if possible!
sorry it is "utf-8"
in blender at least the error is given as "utf-8"
and very annoying
so when I run a script in bl with some unknown characters it gives an error
the problem is how can I find where it is and remove it !
The error in blender is given but does not always shows where it is located in the python script!
even if i had to use a text editor that can locate and then help to remove these characters somehow if possible at all

wxformbuilder and unicode labels

Is there a way to get Unicode characters into label code generated by wxFormBuilder?
For example, to get an Angstrom character the generated string should read u"\u212b".
I tried entering \u212b in the label property field but the resulting string reads u"u212b". So I tried escaping the backslash as \\u212b but that gave me u"\\u212b".
I'm using wxFormBuilder v3.5 - beta. Generating Python code, although the C++ code shows the same behaviour.
By default, wxFormBuilder includes this command (# -- coding: utf-8 --
) on the first line at least for the python code generated.
So I went into MS word and inserted the Angstrom character Ã…, I then copied it into wxFormBuilder (Version 3.5 - RC1) statictext control and it worked on running the code.
Try my approach above instead of typing "u212b". Or type directly in your code like so: u"Hello... Ã…"

Resources