How do you create text-mode graphics? - unicode

I read a post here by #grgarside. He answered a question with a beautifully labelled command using what seems to be only Unicode characters:
┌── ln(1) link, ln -- make links
│ ┌── Create a symbolic link.
│ │ ┌── the path to the intended symlink
│ │ │ can use . or ~ or other relative paths
│ │ ┌─────┴────────┐
ln -s /path/to/original /path/to/symlink
└───────┬───────┘
└── the path to the original file/folder
can use . or ~ or other relative paths
How did he do this? It seems hard to believe that he manually typed the whole thing into a text editor. Is there some type of Unicode editor that makes it easy to create such graphics?
Edit:
as per #grgarside's instruction, except with my Keyboard-en.plist file being in a slightly different location:
Resources ❯ readlink Keyboard-en.plist
/System/Library/Input Methods/PressAndHold.app/Contents/Resources/Keyboard-en.plist
and with the addition towards to the top of the file (note that I needed to use sudo vim Keyboard-en.plist as sublime didn't let me save the file even with sudo subl:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Roman-Accent-k</key>
<dict>
<key>Direction</key>
<string>right</string>
<key>Keycaps</key>
<string>└ ─ ┬ ┘ ┌ ┴ ┐</string>
<key>Strings</key>
<string>└ ─ ┬ ┘ ┌ ┴ ┐</string>
</dict>
<key>Roman-Accent-A</key>
<dict>
<key>Direction</key>
<string>right</string>
<key>Keycaps</key>
<string>A À Á Â Ä Æ Ã Å Ā</string>
<key>Strings</key>
<string>A À Á Â Ä Æ Ã Å Ā</string>
</dict>
...
</dict>
</plist>

I'm the one who wrote the answer in question, and I did craft it manually. I use PressAndHold.app (part of macOS) to add the unicode quickly by holding a character down on the keyboard to insert the characters.
You can use the following in the relevant keyboard plist located at /System/Library/Input Methods/PressAndHold.app/Contents/Resources/Keyboard-en.plist to use the same thing yourself. In my plist, I set ‘k’ as the key to hold.
<key>Roman-Accent-k</key>
<dict>
<key>Direction</key>
<string>right</string>
<key>Keycaps</key>
<string>└ ─ ┬ ┘ ┌ ┴ ┐</string>
<key>Strings</key>
<string>└ ─ ┬ ┘ ┌ ┴ ┐</string>
</dict>

I personally just use the Wikipedia page on unicode box-drawing characters to copy-paste the lines into my answers to write answers such as javascript can't access private properties and Does javascript process using an elastic racetrack algorithm.
Yes it's not as fancy as implementing a custom keyboard binding but I thought I'd just have to write this answer to say that yes, there are people who manually craft answers using only the internet and Stackoverflow's "Your Answer" textarea.

Related

In computer terminology, what do native English speakers call the character set that displays the table in the console?

In computer terminology, what do native English speakers call the character set that displays the table in the console?
Google translate tells me it should be "Tabs".
Is it because I'm not a native English speaker?
This sounds weird to me.
such as
┌ ┬ ┐
├ ┼ ┤
└ ┴ ┘
┏ ┳ ┓
┣ ╋ ┫
┗ ┻ ┛

Pronouncing German words in English

i'm using Google TTS to generate audio files in my native language German.
Unfortunately there are some Words like f.e. "laser" that are pronounced as a German word, but i want it to be pronounced as the English one.
Is there any way in SSML to make it possible or do i have to generate separate audio files and cut them together?
Thanks for your answer!
Try:
<?xml version="1.0"?>
<speak version="1.1" xmlns="http://www.w3.org/2001/10/synthesis"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/10/synthesis
http://www.w3.org/TR/speech-synthesis11/synthesis.xsd"
xml:lang="en-US">
The French word for cat is <w xml:lang="fr">chat</w>.
He prefers to eat pasta that is <lang xml:lang="it">al dente</lang>.
</speak>
Check out the following link:
https://www.w3.org/TR/speech-synthesis11/#edef_lang

VSCode: Delete all occurences of xml tag pair including differing contents

I'm working in a kml (xml) file in VSCode. There are 267 instances of the <description></description> tags with the same contents schema but different contents. I would like a fast way to delete all of the instances of <description> including the contents instead of manually deleting each one. I'm not married to VSCode if Notepad++ or another editor will do what I'm trying to do.
Use one command/macro to delete both of these (plus 265 more)
<description><![CDATA[<center><table><tr><th colspan='2' align='center'>
<em>Attributes</em></th></tr><tr bgcolor="#E3E3F3">
<th>NAME</th>
<td>Anderson</td>
</tr><tr bgcolor="#E3E3F3">
</tr></table></center>]]>
</description>
<description><![CDATA[<center><table><tr><th colspan='2' align='center'>
<em>Attributes</em></th></tr><tr bgcolor="#E3E3F3">
<th>NAME</th>
<td>Billingsly</td>
</tr><tr bgcolor="#F00000">
</tr></table></center>]]>
</description>
Thank you, Paul
You can use this regex in vscode find/replace:
\n?<description>[\S\s\n]*?<\/description>\n?
and replace with nothing. The \n?'s at the beginning and end are there if you want to delete the lines the tags occur on as well - see how it works, you can remove those if you don't care about empty lines where your deleted content used to be.
Obviously, if you have malformed input, like unmatched <description> or </description> tags the regex won't work.

Can anyone tell me what encoding this is?

AAAAAAFuAAIAAAZNYWMgT1MAAAAAAAAAAAAAAAAAAAAAAAAAAADMrsHTSCsAAAALuG8NYWxleHN1Y2tzLmRpYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPJXS83SjIoAAAAAAAAAAP////8AAAkgAAAAAAAAAAAAAAAAAAAAB0Rlc2t0b3AAABAACAAAzK6zwwAAABEACAAAzdJ+egAAAAEADAALuG8AC7hIAADK3wACADFNYWMgT1M6VXNlcnM6AGFuZHJld3ByeWRlOgBEZXNrdG9wOgBhbGV4c3Vja3MuZGljAAAOABwADQBhAGwAZQB4AHMAdQBjAGsAcwAuAGQAaQBjAA8ADgAGAE0AYQBjACAATwBTABIAJ1VzZXJzL2FuZHJld3ByeWRlL0Rlc2t0b3AvYWxleHN1Y2tzLmRpYwAAEwABLwAAFQACABL//wAA
It's a data field from the ~/Library/Preferences/com.microsoft.office.plist file for Microsoft Office 2011 Mac.
It partially decodes using base64 but doesn't appear to be completely base64.
Edit:
Here is another example.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<data>AAAAAAFWAAIAAAZNYWMgT1MAAAAAAAAAAAAAAAAAAAAAAAAAAADMrsHTSCsAAAALuG8HMm5kLmRpYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPgev83SjIoAAAAAAAAAAP////8AAAkgAAAAAAAAAAAAAAAAAAAAB0Rlc2t0b3AAABAACAAAzK6zwwAAABEACAAAzdJ+egAAAAEADAALuG8AC7hIAADK3wACACtNYWMgT1M6VXNlcnM6AGFuZHJld3ByeWRlOgBEZXNrdG9wOgAybmQuZGljAAAOABAABwAyAG4AZAAuAGQAaQBjAA8ADgAGAE0AYQBjACAATwBTABIAIVVzZXJzL2FuZHJld3ByeWRlL0Rlc2t0b3AvMm5kLmRpYwAAEwABLwAAFQACABL//wAA</data>
</plist>
base64 is usually used to encode decode binary files like images. As you would have seen on decoding the above file, it contains few recognizable ASCII strings but most of it is binary.
Property list is a format for storing serialized objects. It is also used for storing settings in Office 2011 Mac. If you are interested in the details for this particular file you can check it here. Scroll to ~/Library/Preferences/com.microsoft.office.plist for the specific format details.
This will help you understand what the ASCII strings mean. To extract and view the plist completely (even binary part) you can use Property List Editor and plutil. (See the source). There are several programs which can do the same.
But if you need to learn how to read and write from plist file (Property List), you can check these links:
http://en.wikipedia.org/wiki/Property_list
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/PropertyLists/Introduction/Introduction.html
It appears to be Base64. The decoded string is
n Mac OS Ì®ÁÓH+ ¸o
alexsucks.dic òWKÍÒŒŠ ÿÿÿÿ Desktop  Ì®³Ã ÍÒ~z  ¸o ¸H Êß 1Mac OS:Users: andrewpryde: Desktop: alexsucks.dic 
a l e x s u c k s . d i c   M a c O S 'Users/andrewpryde/Desktop/alexsucks.dic  / ÿÿ
The encoding is base64, it decodes correctly to a binary file.
Something you'll often see in binary files containing strings is the byte immediately before a string contains the length of the string. This one is no different. If you look at it with a hex editor, the byte immediately before the word "Desktop" has a value of 7.
You're probably stuck with reverse-engineering the point of the file, if there's something other than the text you intend to get out of it, but it mostly just appears to be a reference to some sort of "cleverly" named dictionary file.
FWIW, I used this tool to decode the file.
looks like a binary file defining a dictionary with 32-bit keys (ints?), strings are prefixed with a byte containing the length of the string. Some of the values seems to be padded by zeros. What values do you need to write to?
edit: this tool might help: Package maker

writing subscripts in .plist files

I am trying to represent the number 2 as a subscript in a property list file. I tried using<sub>2</sub>, but it doesn't seem to work. Can anyone help me with this? and will it be stored correctly in a string after I store it there?
A plist file is XML that follows a certain schema. <sub> is not a valid tag in that schema. If you want to put that kind of stuff in the PList, you have to put in into CDATA:
<![CDATA[<sub>2</sub>]]>
A plist file is typically a UTF-8 encoded XML file. You should be able to use the Unicode subscript characters as it is. To copy a non-ASCII char, you can use the Keyboard & Character Viewer (on Lion: System Preferences > Language & Text > Input Sources > Select the Keyboard & Character Viewer as an input source).