I want to print a horizontal line to the console. At the moment, I use -----, but there are small spaces between the single characters.
Is there a better character I might use?
_ is not a viable option, as it is not vertically centered. Is there something like a middlescore, strikethrough (or whatever it's name is) character?
Hyphen ---------------------
Underscore _____________________
EM Dash —————————————————————
Horizontal Bar ―――――――――――――――――――――
Horizontal Box ─────────────────────
There is a big list of characters to try over at wikipedia.
The horizontal box drawing character is my recommendation. It is designed for this purpose
With bash, to display a horizontal rule the size of your window you can use:
printf %"$COLUMNS"s | tr " " "-"
With zsh, you could avoid the tr:
printf '—%.0s' {1..$COLUMNS}
NOTE: I know this is not what OP wants, but it is what I think someone from Google could be seeking.
Unicode character \u2500 solved it for me. According to Wikipedia it is for box drawings light horizontal, which is exactly what I need :-)
Thanks #Gusdor for pointing me to the correct Wikipedia article!
I believe that extended ASCII character #196 can serve your purpose:
See http://www.asciitable.com/
It seems like a vertically-centered non-gap line.
―/― is a horizontal bar character ―
Works for me in terminal.
If you're using Windows, open RUN, type charmap and hit enter.
There are a plenty of characters listed there with previews and names. I'm sure you'll find what you're looking for in charmap.
Update
If you're using a Linux Distribution, check this out.
if working on node js
const line = '#'.repeat(process.stdout.columns || 100);
console.log(line)
function and in Typescript
function consoleLine(mainChar:string, fallbackNum:number):string {
const line = (toRepeat:string) => toRepeat?.repeat(process.stdout?.columns || fallbackNum)
const mainLine = line(mainChar);
const emptyLine = line(' ');
return `${mainLine}\n${emptyLine}\n${mainLine}`;
};
console.log(consoleLine('#', 100));
print a dotted line the width of the console
print('-'*80)
Related
I want to add small straight line onto some desired characters/numbers inside a string inside textview. I couldn't find a solution. Maybe using NSMutableAttributedString. Meanwhile, I mean doing this programmatically. There is strikethrough style, but not overstrike style. Or maybe adding the letters "a" and "_" with different .baseline values. But how to add both characters onto each other then?
Is it possible?
EDIT: Due to make a try for the helpful answers below, I think to make the line at a spesific height is needed. "A\u{0305}" makes the up line very close to the character, as if it sticks. Is there a way to make it at specific height? For example, if we assume that all the keyboard-inputted characters are written inside every single boxes, the ceiling side of these boxes could be lined?
So this (note: see edit below) appears to be an "a tilde ogonek" (it's Lithuanian).
You can write it for instance as follows using these two Unicode characters:
let atildeogonek = "\u{0105}\u{0303}"
let title = "How to add a small straight line (I mean like this: \(atildeogonek)) onto a character inside a string?"
The first character is the a with an ogonek, the second one is the tilde.
EDIT: The initial question specifically asked about the character ą̃ ("a tilde ogonek") in the title, and I used this code to demonstrate how to use Unicode characters in a Swift string. After posting this answer, the question was edited to be more general about "a line above a character".
Programmatically, you could use a function like this:
func overline(character: Character) -> Character? {
return "\(character)\u{0305}".first
}
That will take a character as input and return a new character (glyph) that has had the Unicode combining overline character added to it. It will return nil if adding the combining overline character fails.
The code print(overline(character:"A")!), for example, returns "A̅"
Or, if you want to add an overline to every character in a string, you could use a function like this:
func overline(characters: String) -> [Character?] {
return Array(characters).map { return "\($0)\u{0305}".first
}
}
(I'm not sure if there are any characters for which the above will fail, so I'm not sure if force-unwrapping the result is safe. Thus I left the result of both functions to be optional Character/Array of Character.)
You can easily find the unicodes of ā or ą̃ by using the xcode's own Character Viewer. Just follow the following steps :
hit : Control + Command + SpaceBar
If you get a compact one like this, click the upper right corner icon to expand it.
When expanded, Click the settings gear in the corner . Select customize list.
select Enclosed Characters
Go down to the bottom and open Code tables then add Unicode.
Now, just search for your required Character and you can check its unicode value. here i am searching ā
to print unicode's value :
print("\u{0101}")
I have strokes between numbers that I don't recognise on my keyboard:-
|9|1|
I need to be able to say, if "1" is included in the field include in selection, else exclude. For ";" I have used the following formula, but I don't know what the stroke is?
SUBSTRING(JobSites,6,CHARINDEX('I',JobSites))
Any help appreciated.
Laura
The stroke is a vertical line (Unicode 007C, or Chr(124)), and is commonly referred to as the pipe character, as in pipe-delimited text such as you have posted here. It's typically produced by Shift+\ (the shift key + the backslash key) on most US keyboard layouts.
I believe what you're trying to do can be solved using LIKE:
SELECT <your fields> FROM <your table> WHERE job LIKE '%|1|%`
I'm not even sure if it exists but I'm using this Unicode character as a down indicator http://www.charbase.com/25be-unicode-black-down-pointing-small-triangle (▾) but I need the "up" version...any ideas?
U+25B4 (▴) is technically the up-pointing version of (▾), but it's not exactly the same.
I was using it for showing whether a dropdown element was open and needed it to be exact. So I ended up using CSS transform to flip it. (In my case it was a pseudo-element).
.dropdown::after {
content: '\25BE';
}
.dropdown.active::after {
transform: rotate(180deg);
}
For this character, http://www.unicode.org/charts/PDF/U25A0.pdf contains U+25BE (▾) and related characters.
Looking at the PDF shows U+25B4 (▴) as the black small up-pointing triangle (formally BLACK UP-POINTING SMALL TRIANGLE).
In general, go to http://www.unicode.org/charts and enter the hex number for a character (e.g. 25B4) and it will show you which PDF file describes the related characters. View the PDF; in this case, a quick scan upwards from the down-pointing arrow found the related character code, and the next page shows the formal name and related details.
Do you want U+25B4 BLACK UP-POINTING SMALL TRIANGLE (▴)?
If you know the codepoint of a character and you're trying to find similar ones, try searching the code charts by hex code.
U+25B4 = BLACK UP-POINTING SMALL TRIANGLE. Isn't there a character map you can use installed on your system? I have one (gucharmap - the GNOME [Unicode] Character Map) specifically for occasions like this. Just a suggestion. :-)
In org-mode, I want to give inline code with equals signs and quotation marks:
<div class="foo">
The way I would normally do this in org-mode is
=<div class="foo">=
When I export this to HTML, it gets rendered like this:
<div class"foo">=
What is the right way to do this inline (rather than just creating a source block)?
You could use verbatim markers, ~, instead:
~<div class="foo">~
The problem is that the equals sign after 'class' is interpreted as the closing code section delimiter. You can prevent this by inserting a space before the equals sign, like this:
=<div class = "foo">=
I wanted org-mode's source code to appear correctly in Github's parser. But, just as =:echo "hello"= would not appear correctly in Emacs, it also did not appear correctly in Github. However, I tried other characters with C-x 8 RET, and the LEFT DOUBLE QUOTATION MARK and RIGHT DOUBLE QUOTATION MARK work. That is,
=:echo “hello“=
appear successfully as
:echo “hello“
Unfortunately, I don't think they will actually work if copy-and-pasted into all environments. Vim gives E15: Invalid expression: “hello“. But then, how often do we paste commands into Vim's command line. Well, okay, there is :#".
After almost a decade, here's the correct answer:
Org's escape character is zero width space. When this character is inserted, Emacs will not interpret = as the end of the verbatim. Emacs can correctly interpret =<div class="foo">=. Note that this string has an invisible zero width space character.
However, I think due to a bug, exports from org to other formats, will have this character and need to be removed manually. For example, the export of the string above to markdown will be `<div class="foo">` which is what we want, except that it has an additional zero width space character.
It is not very hard to fix this. Removing all these additional characters can be easily done with replace-string command.
Tip: You can use C-x 8 RET (or insert-char command) and choose 200B to insert zero width space character inside Emacs.
I want to show the dotted line in front of the text (Same as Apple default Keypad Label).
Like as (....hi)
For iOS 6 use NSLineBreakByTruncatingHead of NSLineBreakMode.
From the docs:
NSLineBreakByTruncatingHead The line is displayed so that the end fits
in the container and the missing text at the beginning of the line is
indicated by an ellipsis glyph. Although this mode works for multiline
text, it is more often used for single line text.
For iOS < 6 you can use UILineBreakModeHeadTruncation of UILineBreakMode.
Dot will come automatically. if your text is big compare to label size. Then dot will come
automatically.
In Interface Builder: Line Break Mode -> Truncate Head