how to underline text in python 3.6.5 - python-3.x

How can I print underlined text similar to what is shown on wikipedia in python? What unicode characters would I give to python to make this work?

In Python, arbitrary unicode characters can be expressed with \uXXXX where XXXX is a four-digit hex number identifying the code point.
Wikipedia shows the use of "combining low line" (U+0332).
Since it's a combining character, you need to place it after each character you want to be underlined.
So this code should print aaau̲zzz (u should be underlined in most browsers).
print('aaau\u0332zzz')
Note that this doesn't seem to work very well.
My gnome-terminal (which identifies as GNOME Terminal 3.26.2 Using VTE version 0.50.3 +GNUTLS), using Monospace Regular font, mis-renders the underline on the following character:
But if I copy the resulting text and paste it onto Stack Overflow, it seems to render correctly (Chrome on Linux):
aaau̲zzz
Unless I format it as code:
aaau̲zzz
In which case it doesn't "combine" at all.
Here's a screenshot of the above, in case your browser renders it differently:

Related

Vim: Utf-8 ې character breaks displayed string

I have file that has hex content: db90 3031 46, which should be displayed in vim as "ې" followed by "01F", but what I noticed is that it is never displayed correctly. Then I noticed It is the same in other places like in terminal and browser I always get ې01F? Why is that? Just paste that in google and try yourself you will never be able to put "ې" and 0 as next character.
That's an Arabic character with right-to-left indicator, so you probably need to switch back to left-to-right mode, such as with U+200e.
The Unicode bidirectional stuff is rather complex - the behaviour you are seeing is probably caused by the fact that the Latin digits are marked EN = European number (a weak type), while letters such as F are marked L = left to right (a strong type).
Weak types are treated differently in the Unicode specification, such as with this quote which covers your particular case (my emphasis):
Problematic cases may occur when a right-to-left paragraph begins with left-to-right characters, or there are nested segments of different-direction text, or there are weak characters on directional boundaries. In these cases, embeddings or directional marks may be required to get the right display.
So your code point followed by a digit renders as "ې7" (I typed that 7 in after the Arabic character despite the fact it's showing up before it), while following it with a letter gives "ېX".
For what it's worth, the text "ې‎7" was generated here by inserting ‎ between the two characters, the HTML equivalent of the U+200e Unicode code point.
If you head on over to this UTF-8 codec site and enter %u06D0%u200e7 into the decoding section, you'll see that it comes out in your desired order (removing the %200e shows it in the order you're describing in your question).

Notepad++, windows command line, and unicode

I've been playing around with unicode block elements and box drawing in python3.6, just printing to the command line to see what happens. I've found that only some of the characters will actually print. The full box (2588), halves (258C, 2590), certain lines (2550-256C) will print fine, but the quadrants(2596-2598, 259D), dashed lines (2504-250B), some of the corners, swaths of the intersections show as the boxed question mark. They appear as squared in notepad++ too.
Using the names (\N{QUADRANT LOWER LEFT}) doesn't work either.
According to Wikipedia all the characters should be in UTF-8, which is being used in notepad++, the command line, and Python 3. What's going on?

node JS console log ascii symbol

HiI am using node JS for my app, and I want to print ascii symbols in terminal.Here is a table for ascii symbols. Please check Extended ASCII Codes field. I want to print square or circle, for example 178 or 219.
Can anyone say me, how can do it?Thank you
Like several other languages, Javascript suffers from The UTF‐16
Curse. Except that Javascript has an even worse form of it, The UCS‐2
Curse. Things like charCodeAt and fromCharCode only ever deal with
16‐bit quantities, not with real, 21‐bit Unicode code points.
Therefore, if you want to print out something like 𝒜, U+1D49C,
MATHEMATICAL SCRIPT CAPITAL A, you have to specify not one character
but two “char units”: "\uD835\uDC9C".
Please refer to this link: https://dheeb.files.wordpress.com/2011/07/gbu.pdf
Your desired character is not a printable ASCII character. On linux you can print all the printable ascii characters by running this command:
for((i=32;i<=127;i++)) do printf \\$(printf '%03o\t' "$i"); done;printf "\n"
or
man ascii
So what you can do is to print unicode characters. Here is a list of all the available unicode characters, and you can select one which is looking almost identical with your desired character.
http://unicode-table.com/en/#2764
I've tested on a windows terminal but it is still not showing the desired character, but it's working on linux. If it's still not working you had to make sure to set LANGUAGE="en_US.UTF-8" in /etc/rc.conf and LANG="en_US.UTF-8" in /etc/locale.conf.
So printing out something like this on node console:
console.log('\u2592 start typing...');
will output this result:
▒ start typing...
Actually, if you only care about ASCII that should not be a real problem at all. You only have to properly escape them. A good reference for this is https://mathiasbynens.be/notes/javascript-escapes
console.log('\xB2 \xDB')
Works for me with recentish node under Windows (cmd shell) and mac OS. For ASCII characters you can just convert them to hex and prepend them with \x in your strings. Give it a try with node -e "console.log('\xB2')"
And when you try this answer, and it works, you might want to try:
node -e "console.log('\x07')"

Unicode underline does not completely underline some characters

I have a string in a C# application that needs to be underlined. This needs to be done in unicode as the string is exported and displayed in a word file. To do this I preceded every character with the underline unicode \u0332which works, but it does not completely underline the 'm' character as seen in this screenshot:
I have tried preceding the \u0332 a few times before the m and after but the output is always the same.
Is there any way to get it to completely underline the character?
EDIT: I just tried using the continuous underline unicode symbol \u2381 but that does not render at all.
U+0332 is a Unicode combining character, so ist goes after the character that it modifies. But this only specifies that the character should be underlined. The specific graphical representation depends on the application and its rendering engine; it's not fully supported everywhere. Try to paste the text i̲m̲p̲o̲r̲t̲a̲n̲t̲ into the application and see if it works as intended. If not, then there is nothing you can do, except using another representation such as *important* or IMPORTANT, or exporting in a supported rich text format (RTF, docx, etc.).

How to handle unicode strings in a XeLaTeX document?

an earlier question led me to XeLaTex (it was about LaTeX and Unicode). So I've got now this document:
\documentclass[a4paper]{article}
\usepackage[cm-default]{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\setmainfont[Mapping=tex-text]{Arial}
\begin{document}
গ a ä ͷ
\end{document}
With the font "Arial" only the a and the ä are displayed, the other two characters are only a box each. If I remove the \setmainfont-command, only the a is displayed. If I change "Arial" to "Linux Libertine" I receive an error message:
Illegal fontname `Linux Libertine':
contains ' '
This is irritating, because the WikiPedia-Example about XeLaTeX has a font-name containing spaces.
What do I have to do to make all the given chars appear in my pdf-document?
If the fonts are correctly installed, they should work as expected (at least they work for me). However, neither Arial nor Linux Libertine contain all four characters. Especially the first character is supported only by a tiny number of fonts (see this list). The following example uses Code2000 and displays all characters correctly:
\documentclass[a4paper]{article}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\setmainfont{Code2000}
\begin{document}
গ a ä ͷ
\end{document}
Ah, I see; I should have actually tried out your example. The OpenType name of the font isn't Linux Libertine, it's Linux Libertine O. Alternatively, you can use the PostScript name:
\setmainfont{LinLibertineO}
Still, this font doesn't have all those four characters either. You might have a hard time finding one that does.
Apparently you need your font to support your Unicode characters. TeX Gyre Pagella, as suggested here, works for me for some Central European diacritic characters and Cyrillic.
sorry guys to answer so late, but I actually did what i wanted:
http://www.julianmoritz.de/dl/poster.pdf
regards!
you probably won't be able to load TeX Gyre Pagella with XeTeX or XeLaTeX. Switch back to regular LaTeX and do this in your preamble:
\usepackage[T1]{fontenc}
\usepackage{tgpagella}

Resources