Generate Tiny Text

1

Challenge

Your program needs to take an input of a string, where the string has only letters, no special characters, no numbers, and no accents (they look all weird).

Then, your program should output a superscript version.

Example

Input: hello world

Output: ʰᵉᶫᶫᵒ ʷᵒʳᶫᵈ

Test Cases

hello - ʰᵉᶫᶫᵒ
code - ᶜᵒᵈᵉ
golf - ᵍᵒᶫᶠ
asdf - ᵃˢᵈᶠ
qwerty - ᑫʷᵉʳᵗʸ
abcdefghijklmnopqrstuvwxyz - ᵃᵇᶜᵈᵉᶠᵍʰᶦʲᵏᶫᵐᶰᵒᵖᑫʳˢᵗᵘᵛʷˣʸᶻ

Help

If you need help understanding check out this website, it's a translator: http://txtn.us/tiny-text

Code Golf

This is a code golf, so the shortest code wins!

Good luck!

Edits

Edit #1: There will be no caps, since I just realized they look weird.

Noah Cristino

Posted 2017-05-29T10:44:08.897

Reputation: 667

Question was closed 2017-05-29T11:32:02.783

2Will they be all lowercase? – ASCII-only – 2017-05-29T10:47:16.193

Related – Beta Decay – 2017-05-29T10:48:11.360

@BetaDecay They're related but this is superscript – Noah Cristino – 2017-05-29T10:49:37.733

@BetaDecay Oops, sorry. – Noah Cristino – 2017-05-29T10:51:42.287

@ASCII-only I changed my mind, see edit, all lowercase. – Noah Cristino – 2017-05-29T10:53:27.333

tr is tr, and changing the second argument from small caps to superscript doesn't make a fundamentally different question. – Peter Taylor – 2017-05-29T11:33:02.127

"output superscript version" - output where? If I am not mistaken, there is no even such a thing as unicode latin superscript letters. If so this does not make sense for text output, and should be tagged graphical-output or browser. – Mikhail V – 2017-05-29T13:52:59.587

Also in your examples I see letters I, L, N, as caps and q as normal size, so it does not work in Firefox. – Mikhail V – 2017-05-29T13:59:28.867

@MikhailV it's unicode: https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts

– Noah Cristino – 2017-05-29T15:08:17.103

yes that's what I am saying " the Unicode standard contains superscript and subscript versions of a subset of Latin ... these characters come from different ranges, they may not be of the same size and position, depending on the typeface" So there is no standard latin superscript in unicode. – Mikhail V – 2017-05-29T15:18:52.947

@MikhailV but it's still in unicode – Noah Cristino – 2017-05-29T15:19:45.480

Answers

5

JavaScript (ES6), 10 bytes

s=>s.sup()

It should be noted that the sup() method has been deprecated so this solution may not work in all browsers nor is it guaranteed to continue working in future releases of browsers that do currently support it. Tested and confirmed to work in Chrome v58.


Try it

f=
s=>s.sup()
o.innerHTML=(i.value="Hello!")+": "+f(i.value)
oninput=_=>o.innerHTML=i.value+": "+f(i.value)
*{font-family:arial,sans-serif}
<input id=i><p id=o>

Shaggy

Posted 2017-05-29T10:44:08.897

Reputation: 24 623

Can you add a code snippet try me thing? – Noah Cristino – 2017-05-29T10:48:38.197

@NoahCristino, Snippet added. – Shaggy – 2017-05-29T10:52:38.200

@Shaggy That's weird, when I converted something like: CAPSLOCK@^&@^& with the website, I get: ᶜᴬᴾˢᴸᴼᶜᴷ@^﹠@^﹠, but with your it works right. – Noah Cristino – 2017-05-29T10:55:41.370

@Shaggy Yeah, that's probably it – Beta Decay – 2017-05-29T10:55:55.483

Deprecated, but still works with all major browsers so gets my vote: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/sup

– Rick Hitchcock – 2017-05-29T11:02:23.690

@RickHitchcock: Yep, was editing that point into my answer as you were commenting. – Shaggy – 2017-05-29T11:06:09.623

3

PHP+HTML, 17 Bytes

<sup><?=$_GET[0];

Jörg Hülsermann

Posted 2017-05-29T10:44:08.897

Reputation: 13 026

Doesn't this still display normal characters, in a superscript size and position? – L3viathan – 2017-05-29T10:56:30.960

1<sup><?=$_GET[0]; – Christoph – 2017-05-29T11:03:30.177

@L3viathan Yes and the input is limited to letters – Jörg Hülsermann – 2017-05-29T11:13:51.193

How is it limited to letters? – Shaggy – 2017-05-29T11:14:44.480

@Shaggy The OP says Your program needs to take an input of a string, where the string has only letters, no special characters, no numbers, and no accents (they look all weird). – Jörg Hülsermann – 2017-05-29T11:15:50.200

Ah, I thought you were implying that your code stripped out non-letter characters - I couldn't see how it was possibly doing that! :D – Shaggy – 2017-05-29T11:17:27.033

@JörgHülsermann The input is letters, but the output is (in my understanding) supposed to be superscript characters (e.g. U+1D43 for a), not just look like them. – L3viathan – 2017-05-29T11:22:13.823

@Shaggy Yes it do the same that your JS answer do – Jörg Hülsermann – 2017-05-29T11:26:19.510

1@L3viathan If your understanding is right there are two other invalid answers from Shaggy and Kevin Cruijssen – Jörg Hülsermann – 2017-05-29T11:32:15.593

2

Mathematica, 13 bytes

#~Style~Tiny&

J42161217

Posted 2017-05-29T10:44:08.897

Reputation: 15 931

2

Java 8 (AWT / Swing), 79 bytes

s->new java.awt.Frame(){{add(new javax.swing.JLabel("<html><sup>"+s));show();}}

Unfortunately there is no reliable online compiler available for Java GUI, so no TIO-link.

Java 8 (Console), 123 117 bytes

s->{for(int x:s.toCharArray())System.out.print("ᵃᵇᶜᵈᵉᶠᵍʰᶦʲᵏᶫᵐᶰᵒᵖᑫʳˢᵗᵘᵛʷˣʸᶻ".charAt(x-97));}

Try it here.

Kevin Cruijssen

Posted 2017-05-29T10:44:08.897

Reputation: 67 575

Do you need the <html> tag? – Shaggy – 2017-05-29T11:53:39.653

@Shaggy Unfortunately yes, I've already tried without it when I posted the answer. Without it just outputs <sup>sometext literally. It will probably enable html if it sees the <html> text in the JLabel. – Kevin Cruijssen – 2017-05-29T12:01:40.250

1

Pyth, 75 bytes (30 chars)

XwG"ᵃᵇᶜᵈᵉᶠᵍʰᶦʲᵏᶫᵐᶰᵒᵖᑫʳˢᵗᵘᵛʷˣʸᶻ

Try it!

KarlKastor

Posted 2017-05-29T10:44:08.897

Reputation: 2 352