53
\$\begingroup\$

Portable Spec.

Iɴꜱᴘɪʀᴇᴅ ʙʏ @ConorO'Brien's ᴜꜱᴇʀɴᴀᴍᴇ.

Aʟꜱᴏ ᴛʜᴀɴᴋꜱ ᴛᴏ @Dᴏᴏʀᴋɴᴏʙ ꜰᴏʀ ꜱʜᴏᴡɪɴɢ ᴍᴇ ᴛʜᴇ ᴇxɪꜱᴛᴇɴᴄᴇ ᴏꜰ ǫ ᴀɴᴅ x.

Sᴍᴀʟʟ Cᴀᴘꜱ ᴀʀᴇ ᴘʀᴇᴛᴛʏ ᴄᴏᴏʟ. Tʜᴇʏ ᴀʀᴇ ᴜɴɪᴄᴏᴅᴇ ᴄʜᴀʀᴀᴄᴛᴇʀꜱ ᴛʜᴀᴛ ʀᴇᴘʟᴀᴄᴇ ꜱᴍᴀʟʟ ʟᴇᴛᴛᴇʀꜱ. Tʜᴇʏ ʟᴏᴏᴋ ᴊᴜꜱᴛ ʟɪᴋᴇ ᴛʜᴇ ᴄᴀᴘɪᴛᴀʟ ᴏɴᴇꜱ, ʙᴜᴛ ꜱᴍᴀʟʟᴇʀ, ᴀɴᴅ ʟᴏᴏᴋ ʀᴇᴀʟʟʏ ᴏꜰꜰɪᴄɪᴀʟ. Yᴏᴜʀ ᴛᴀꜱᴋ ɪꜱ ᴛᴏ ᴡʀɪᴛᴇ ᴀ ᴘʀᴏɢʀᴀᴍ ᴛʜᴀᴛ ᴄᴏɴᴠᴇʀᴛꜱ ʀᴇɢᴜʟᴀʀ ᴛᴇxᴛ ɪɴᴛᴏ ꜱᴍᴀʟʟ ᴄᴀᴘꜱ.

Hᴇʀᴇ ɪꜱ ᴀ ʟɪꜱᴛ ᴏꜰ ᴛʜᴇ ᴜɴɪᴄᴏᴅᴇ ᴄʜᴀʀᴀᴄᴛᴇʀꜱ ꜰᴏʀ ꜱᴍᴀʟʟ ᴄᴀᴘꜱ:

ᴀ ʙ ᴄ ᴅ ᴇ ꜰ ɢ ʜ ɪ ᴊ ᴋ ʟ ᴍ ɴ ᴏ ᴘ ǫ ʀ ꜱ ᴛ ᴜ ᴠ ᴡ x ʏ ᴢ

Cʟᴀʀɪꜰɪᴄᴀᴛɪᴏɴꜱ

  • Rᴇɢᴜʟᴀʀ ᴄᴀᴘꜱ ʀᴇᴍᴀɪɴ ʀᴇɢᴜʟᴀʀ ᴄᴀᴘꜱ ᴀɴᴅ ꜱᴏ ᴅᴏ ᴘᴜɴᴄᴛᴜᴀᴛɪᴏɴꜱ, ꜱᴘᴀᴄᴇꜱ, ᴇᴛᴄ.
  • Iɴᴘᴜᴛ ᴄᴀɴ ʙᴇ ᴍᴜʟᴛɪᴘʟᴇ ʟɪɴᴇꜱ.
  • Tʜɪꜱ ɪꜱ , ꜱᴏ ꜱʜᴏʀᴛᴇꜱᴛ ᴄᴏᴅᴇ ɪɴ ʙʏᴛᴇꜱ ᴡɪɴꜱ!

Tᴇꜱᴛ Cᴀꜱᴇꜱ

Hello World -> Hᴇʟʟᴏ Wᴏʀʟᴅ

abcdefghijklmnopqrstuvwxyz -> ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ

Welcome to Programming Puzzles and Code Golf Stackexchange!
It is a website ->
Wᴇʟᴄᴏᴍᴇ ᴛᴏ Pʀᴏɢʀᴀᴍᴍɪɴɢ Pᴜᴢᴢʟᴇꜱ ᴀɴᴅ Cᴏᴅᴇ Gᴏʟꜰ Sᴛᴀᴄᴋᴇxᴄʜᴀɴɢᴇ!
Iᴛ ɪꜱ ᴀ ᴡᴇʙꜱɪᴛᴇ.
\$\endgroup\$
22
  • 7
    \$\begingroup\$ What are all of those boxes? I think they are ss... \$\endgroup\$
    – Justin
    Oct 12, 2015 at 2:29
  • 83
    \$\begingroup\$ F and S are boxes for me. The rest are fine, for some reason. \$\endgroup\$ Oct 12, 2015 at 2:30
  • 11
    \$\begingroup\$ I feel obligated fo answer, now. :P \$\endgroup\$ Oct 12, 2015 at 2:57
  • 10
    \$\begingroup\$ Any ideas what the font situation is that causes the F and S not to render for a lot of us? \$\endgroup\$ Oct 12, 2015 at 4:27
  • 55
    \$\begingroup\$ There is no dedicated Unicode character range for "small caps". The letters are taken from several different character ranges, intended for phonetic pronunciations. Therefore, the character codes are out of order (making this programming task more interesting), and fonts may have support for some, but not others. The missing F and S is because your font has support for the IPA Extensions and Phonetic Extensions Unicode block, but not the Latin Extended-D block, which is where small F and S are defined. \$\endgroup\$
    – David Yaw
    Oct 12, 2015 at 4:37

22 Answers 22

30
\$\begingroup\$

Retina, 73 bytes

T`a-z`ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ

This is exactly what Retina's transliterate mode was made for. It replaces all lowercase letters (a-z) with their corresponding small caps version. Annoyingly, the character codes of the small caps characters are all over the place, so it can't take advantage of ranges for the second part: ideally it would be T`a-z`ᴀ-ᴢ.

Try it online.

\$\endgroup\$
2
  • 8
    \$\begingroup\$ It's not really surprising - what's surprising, bearing in mind the rules for what gets to be a unicode character, is that all of the small caps characters are defined in the first place. \$\endgroup\$
    – Random832
    Oct 12, 2015 at 13:52
  • 3
    \$\begingroup\$ It's not surprising. You can see the same in Unicode subscript and superscript characters. ¹, ² and ³ exist in ISO-8859-1 long before Unicode, so they are in a separated block from the rest digits and letters \$\endgroup\$
    – phuclv
    Oct 12, 2015 at 14:03
25
\$\begingroup\$

Pyth, 61 59 58 bytes

LXbGsmC+*7389<dGCd"#ʙ'(*ꜰɢʜɪ-.ʟ0ɴ2;ǫʀꜱ>?CDxʏE

This defines a named function y. Try it online in the Pyth Compiler/Executor.

The code contains no unprintable characters.

Idea

Among the small caps, there are 14 characters in the range 7424 – 7458, and all of them require three bytes to be stored verbatim. By subtracting 7389 from their code points, we map them in the printable ASCII range 35 – 69, so each of them will occupy only one byte.

To decode the string, we simply add 7389 to the code points of all characters that come before a.

Code

L                       Define y(b):
 Xb                       Transliterate b...
   G                      by replacing the lowercase ASCII letters...
                          with the characters of result of the following:
     m            "…          Map; for each d in that string:
        *7389<dG              Calculate (7389 * (d < 'abc...xyz')).
       +        Cd            Add the product to int(d).
      C                       Cast to character.
    s                       Turn the resulting char array into a string.
\$\endgroup\$
12
\$\begingroup\$

Javascript (ES6), 114 bytes

a=>a.replace(/[a-z]/g,b=>'ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ'[b.charCodeAt()-97])

// snippet
var o = document.getElementById("o");
var t = document.getElementById("t");
t.onkeyup = _=>o.textContent = (a=>a.replace(/[a-z]/g,b=>'ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ'[b.charCodeAt()-97]))(t.value);
<!-- snippet -->
<input id="t" placeholder='Sample Text' />
<pre id="o"></pre>

\$\endgroup\$
3
  • \$\begingroup\$ Unless you're targetting IE8 or earlier, I'd suggest preferring oninput to onkeyup. \$\endgroup\$
    – Neil
    Oct 15, 2015 at 19:56
  • \$\begingroup\$ @Neil ok, will do in the future \$\endgroup\$
    – DankMemes
    Oct 15, 2015 at 20:20
  • \$\begingroup\$ It's 1 byte cheaper to match everything, and default to b: a=>a.replace(/./g,b=>'ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ'[b.charCodeAt()-97]||b) \$\endgroup\$ Jun 9, 2022 at 3:43
11
\$\begingroup\$

CJam, 78 74 67 66 63 bytes

q'{,97>"#ʙ'(*ꜰɢʜɪ-.ʟ0ɴ2;ǫʀꜱ>?CDxʏE"{_'a<7389*+}%er

This uses the same idea as my other answer.

The code contains no unprintable characters. Try it online in the CJam interpreter.

How it works

q       e# Read all input and push it on the stack.
'{,     e# Push the range of all characters up to 'z'.
97>     e# Remove the first 97 characters. This leaves lowercase letters.

"#ʙ'(*ꜰɢʜɪ-.ʟ0ɴ2;ǫʀꜱ>?CDxʏE"

{       e# Map; for each character in that string:
  _'a<  e#   Check if a copy of the character is lower than 'F'. Pushes 1 or 0.
  7389* e#   Multiply the resulting Boolean by 7389.
  +     e#   Add the product to the character's code point.
}%      e#
er      e# Perform transliteration; replace each letter in the input by the
        e# corresponding character of the modified string.
\$\endgroup\$
0
10
\$\begingroup\$

Python 3, 140 bytes

import sys;print(sys.stdin.read().translate(dict(zip(range(97,123),'ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ'))))

Try it online!

Hooray for built-in Unicode support! Now works with multi-line input.

-10 bytes thanks to @Bakuriu

\$\endgroup\$
2
  • \$\begingroup\$ why not {x for x in zip(range(97,123), ...)}? afaik this is the same length of what you have, but now you can shorten the code by using dict(zip(...)) resulting in 10 less bytes or so. \$\endgroup\$
    – Bakuriu
    Oct 12, 2015 at 19:34
  • \$\begingroup\$ @FelipeNardiBatista input() only takes single-line input. The challenge specifies that multi-line input needs to be handled. \$\endgroup\$
    – user45941
    May 29, 2017 at 16:27
8
\$\begingroup\$

><>, 118 116 Bytes

-2 bytes thanks to @torcado.

I'll try to think of a way to remove that entire alphabet from my code later.

I haven't been able to test it with newlines, but I see no reason for it not working with them.

!oi:0(?;::"{"($"`")*0$.
v"a"%&"ᴢʏxᴡᴠᴜᴛꜱʀǫᴘᴏɴᴍʟᴋᴊɪʜɢꜰᴇᴅᴄʙᴀ"&
>:?!v1-$~
~00.>

Try it online.

Emoticons found in the code: 0:(, :0, :"{, >:, 0=, and the debatable ones: i:, >:?, :?, ?;

\$\endgroup\$
4
  • 2
    \$\begingroup\$ Oh wow i love how you used the true/false results for the jump position! You can shave off 2 bytes by using >:?!v1-$~ and ~00.> as your last 2 lines \$\endgroup\$
    – torcado
    Oct 12, 2015 at 6:06
  • \$\begingroup\$ @torcado Thanks, changing now. \$\endgroup\$
    – cole
    Oct 12, 2015 at 12:54
  • \$\begingroup\$ More emoticons: :0(, :? \$\endgroup\$
    – DanTheMan
    Oct 12, 2015 at 20:20
  • \$\begingroup\$ @DanTheMan I was debating those but I guess I'll add them. \$\endgroup\$
    – cole
    Oct 13, 2015 at 3:51
6
\$\begingroup\$

Julia, 126 bytes

t->join([(i=Int(c);96<i<123?split("ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ","")[i-96]:c)for c=t])

Ungolfed:

function f(t::AbstractString)
    # Split the small caps into an array (this particular Unicode
    # string does not like to be indexed for whatever reason)
    s = split("ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ", "")

    # Create an array with replaced letters
    r = [(i = Int(c); 96 < i < 123 ? s[i-96] : c) for c in t]

    # Join the array back into a string
    join(r)
end
\$\endgroup\$
2
  • \$\begingroup\$ Where does AbstractString fit into the golfed code? \$\endgroup\$
    – clapp
    Dec 12, 2015 at 20:33
  • \$\begingroup\$ @VoteToSpam It doesn't; it's just there in the ungolfed code to illustrate the type of input that's expected. It's entirely unnecessary beyond that. \$\endgroup\$
    – Alex A.
    Dec 12, 2015 at 20:47
5
\$\begingroup\$

Perl 5, 84 bytes

(83 bytes script and -p)

use utf8;y/a-z/ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ/

Nothing particularly different, but it's worth noting the necessity of the use utf8; statement to get legible text. A warning is displayed as well, but I believe the consensus is that they are acceptable:

$perl -p smallcaps.pl <<< 'Programming Puzzles and Code Golf' 
Wide character in print, <> line 1.
Pʀᴏɢʀᴀᴍᴍɪɴɢ Pᴜᴢᴢʟᴇꜱ ᴀɴᴅ Cᴏᴅᴇ Gᴏʟꜰ
$perl -p smallcaps.pl <<< 'Programming Puzzles and Code Golf' 2> /dev/null
Pʀᴏɢʀᴀᴍᴍɪɴɢ Pᴜᴢᴢʟᴇꜱ ᴀɴᴅ Cᴏᴅᴇ Gᴏʟꜰ

Perl, 80 bytes

(74 bytes script and -pMutf8)

Thanks @hobbs!

y/a-z/ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ/
$perl -pMutf8 -e'y/a-z/ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ/' <<< 'Programming Puzzles and Code Golf' 2> /dev/null
Pʀᴏɢʀᴀᴍᴍɪɴɢ Pᴜᴢᴢʟᴇꜱ ᴀɴᴅ Cᴏᴅᴇ Gᴏʟꜰ
\$\endgroup\$
2
  • \$\begingroup\$ Subtract 9 for use utf8; and add 5 for -Mutf8. \$\endgroup\$
    – hobbs
    Oct 12, 2015 at 17:39
  • \$\begingroup\$ @hobbs Of course! I did play with that earlier, but I'm often unsure how to score correctly when abusing a lot of the commandline switches... I'll add that in! \$\endgroup\$ Oct 12, 2015 at 17:47
5
\$\begingroup\$

05AB1E, 73 bytes (non-competing)

Yet again, I wish Adnan had published this language earlier.

A"ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ"‡

Try it online!

Explanation:

A                              - Push a-z
 "ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ"   - Push "ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ"
                             ‡ - Pop a, b, c Push a.transliterate(b -> c)
\$\endgroup\$
3
\$\begingroup\$

Ruby, 89 bytes

p ARGV[0].tr "a-z","ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ"

To use:

ruby <file-name> "<string>"
\$\endgroup\$
3
  • \$\begingroup\$ Welcome to Programming Puzzles & Code Golf! I'm not sure if surrounding the output in quotes is allowed, but you can save a few bytes by turning your code into a lambda. ->s{s.tr"a-z","ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ"} is only 84 bytes. \$\endgroup\$
    – Dennis
    Oct 12, 2015 at 13:09
  • \$\begingroup\$ (After reading the question again, I'm not sure function are allowed. A few answers are using functions. I'll request clarification from the OP.) \$\endgroup\$
    – Dennis
    Oct 12, 2015 at 13:13
  • 1
    \$\begingroup\$ you can replace p ARGV[0] with p$*[0] to save 3. ` \$\endgroup\$
    – AShelly
    Oct 13, 2015 at 16:13
3
\$\begingroup\$

Julia, 105 bytes

t->map(c->96<c<123?["ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ"...][c-'`']:c,t)

This is simple - for each character in t, it checks to see if the character, c, is lowercase (96<c<123) - if it is, it subtracts the character with value 96 ('`') from the character, and looks up the corresponding character in the array [ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ"...]. If it's not lowercase, then just use c itself. The map function applies this procedure for each character in the string.

Alternative, if we can restrict input to ASCII less than 127:

Julia, 104 bytes

t->join(['\1':'`';"ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ{|}~"...][t.data])

In this case, the array is longer, including all characters between ASCII 1 ('\1') and 126 ('~'), with the lowercase letters replaced as appropriate - it then uses the characters in t, expressed as unsigned integers (t.data), to lookup the values in the array, and joins the new characters back into a string at the end.

\$\endgroup\$
3
\$\begingroup\$

Sed, 97 bytes

y/abcdefghijklmnopqrstuvwxyz/ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ/
\$\endgroup\$
3
  • \$\begingroup\$ I am not a sed user but can abcdefghijklmnopqrstuvwxyz be replaced with a-z to save many bytes? \$\endgroup\$
    – clapp
    Oct 14, 2015 at 4:20
  • \$\begingroup\$ No, sadly it can't. I didn't post this as something competitive with the best solutions here, just because it's something easy to do with sed. It's also a good test of sed - broken, non-multibyte-aware sed implementations like the one in busybox (and perhaps ones in some proprietary unices?) will likely fail to run it. \$\endgroup\$ Oct 14, 2015 at 4:25
  • \$\begingroup\$ Okay, that is a shame. Great answer, though! \$\endgroup\$
    – clapp
    Oct 14, 2015 at 4:35
3
\$\begingroup\$

Java, 306 275 217 215 189 bytes

Well, Java is definetely not the best language to accomplish this task in... but, here it is anyway:

void p(String s){for(int i=1;i<27;s=s.replace("abcdefghijklmnopqrstuvwxyz".charAt(++i),"ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ".charAt(i)));System.out.print(s);

Thanks to @ThomasKwa and @DHall for help in shaving off 91 characters!

\$\endgroup\$
5
  • 2
    \$\begingroup\$ @ThomasKwa it probably can be golfed more, but the unicode shoots up the byte count. \$\endgroup\$
    – GamrCorps
    Oct 12, 2015 at 4:29
  • \$\begingroup\$ @ThomasKwa Yep, you were right. Had some debug code left in there.... \$\endgroup\$
    – GamrCorps
    Oct 12, 2015 at 14:07
  • 1
    \$\begingroup\$ a couple hints to improve this further: 1)string.replace(str1, str2) replaces ALL instances of str1 with str2, and returns the original string as is if str1 isn't found. 2)this is O(n), can you make it O(1) ? \$\endgroup\$
    – DHall
    Oct 12, 2015 at 17:01
  • \$\begingroup\$ @DHall looking over it, str.replace() would likely be shorter. At work now so I'll try to fix it once I get home. \$\endgroup\$
    – GamrCorps
    Oct 12, 2015 at 17:14
  • \$\begingroup\$ Ignore my previous deleted comment, I misread the specs. However, you can still golf it like this void p(String s){for(char c:s.toCharArray())System.out.print(c>96&c<123?"ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ".charAt(c-97):c);} (PS: You're missing a closing bracket (}) in your current answer.) \$\endgroup\$ May 29, 2017 at 12:19
2
\$\begingroup\$

Scala, 125 bytes

(s:String)=>s.map(c=>('a'to'z'zip "ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ"toMap).getOrElse(c,c))

An anonymous function that has string as an input and output. Iterate through its chars and get the unicode version of them by matching them from dict/map. Return original char if the unicode one doesn't exist.

Usage

  1. Open Scala REPL and paste the code above
  2. It will create a function (resX) that can be called by passing a string (e.g. resX("my String"))
\$\endgroup\$
2
\$\begingroup\$

Perl 6, 78 bytes

The simplest command line version:

$ perl6 -pe'tr/a..z/ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ/' # 76 + 2 = 78

It gets a bit larger if you put it into a file.

$_=$*IN.slurp-rest;tr/a..z/ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ/;.print # 102
\$\endgroup\$
2
\$\begingroup\$

Sacred JavaScript ES6, 600 Bytes

Hey look, I answered!

( ))) ) )( ) ))( ))) () (((  (( ()((( ))( )  ( )() (((( () ) () ( () )( )(( ((() () (((  (( ()((( (( (((((((() ) )( ) ))((  )( ) )((( ) ( () )( )(( ) (( ) ( ()(((((( (((( ()() )    ((() ( () () (( )( ( )) ((   ((    (((( ()(  ((() () (((  (( ()((( (( (((( (((((( () (())( ) ) ((() ) )( ) )) ( )((()))) ())() ( () ((() )  ( ()((()() ) )(()) ()(  ()( () )()()(( () )(()(()())()   ()()) ( ( ) ()))))    )  (()  ()(((( )  )()  )  ( )(( ( (( ) )( ((  ((()( ( ((((() () (( )  ( )()( ()((( )  )((((( ( ( ) (( ) ) )( )(( )) (((( ((() ()   ) (  )  (( (( ((()(((()((((() ((() () (( ))((( ( ( )) ((  )( () ( () 

Here's a cool image:

JavaScript ES6, 120 Bytes

This is the code.

k=>k.match(/./g).map(z=>new Array(26) .fill(0).map((q,e)=>"ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ"[e])[z.charCodeAt()-97]||z).join``)

This is the snippet.

while(1)alert(prompt().match(/./g).map(z=>new Array(26) .fill(0).map((q,e)=>"ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ"[e])[z.charCodeAt()-97]||z).join``

\$\endgroup\$
2
\$\begingroup\$

Python, 99 bytes

def s(t):return"".join([(a,"ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ"[(ord(a)+7)%26])[96<ord(a)<123] for a in t])

I tried to find some pattern in the Unicode codes for small capitals, but I'm not sure there is one.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ You can shorten this by using a lambda: instead of def s(t):return, use lambda t: \$\endgroup\$
    – pxeger
    Jun 9, 2022 at 6:48
  • 1
    \$\begingroup\$ Some more golfs bring this to 127 bytes (86 chars) as you need to count this in UTF-8. \$\endgroup\$
    – emanresu A
    Jun 9, 2022 at 6:59
2
\$\begingroup\$

Japt v2.0a0, 81 80 78 75 bytes

r\aÈcg"ʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢᴀʙᴄᴅᴇꜰɢ

Try it

\$\endgroup\$
2
  • \$\begingroup\$ If you move ᴀʙᴄᴅᴇꜰɢ to the end of the string you can remove the 7+ :-) \$\endgroup\$ May 29, 2017 at 16:16
  • \$\begingroup\$ So I can. Thanks, once again, @ETHproductions :) \$\endgroup\$
    – Shaggy
    May 29, 2017 at 16:27
2
\$\begingroup\$

Raku, 69 bytes

{S:g[(q)|<[a..wyz]>]=$0??'ǫ'!!'ᴀ'.uniname.subst(/.$/,$/).uniparse}

Try it online!

Special handling for q; for other lowercase letters other than x, generate the Unicode name for the small caps (eg, LATIN LETTER SMALL CAPITAL S) and parse it.

I saved a few bytes by using the Unicode name of the character (LATIN LETTER SMALL CAPITAL A) as a template, and replacing the final character with the letter I want to convert.

\$\endgroup\$
2
\$\begingroup\$

Vyxal U, 56 bytes

ka`#Ẏṗ'(*¥ṫ§Ẋ⟨ẎṫẊ₅-.Ẏẏ0Ẋ¦2;Ṫ₆Ẏ↓¥ṫε>?CDxẎḋE`C:70<7389*+CĿ

Try it Online!

Port of CJam.

How?

ka`#Ẏṗ'(*¥ṫ§Ẋ⟨ẎṫẊ₅-.Ẏẏ0Ẋ¦2;Ṫ₆Ẏ↓¥ṫε>?CDxẎḋE`C:70<7389*+CĿ
ka                                         # Push the lowercase alphabet
  `#Ẏṗ'(*¥ṫ§Ẋ⟨ẎṫẊ₅-.Ẏẏ0Ẋ¦2;Ṫ₆Ẏ↓¥ṫε>?CDxẎḋE` # Push string "#ʙ'(*ꜰɢʜɪ-.ʟ0ɴ2;ǫʀꜱ>?CDxʏE"
                             C             # Convert to character codes: [35, 665, 39, 40, 42, 42800, 610, 668, 618, 45, 46, 671, 48, 628, 50, 59, 491, 640, 42801, 62, 63, 67, 68, 120, 655, 69]
                              :            # Duplicate
                               70<         # For each, is it less than 70?
                                  7389*    # Multiply by 7389
                                       +   # Add
                                        C  # Convert from character codes
                                         Ŀ # Transliterate the implicit input from the lowercase alphabet to this

Previous answer:

Vyxal, 61 bytes

ka»7ȧ∵ẋǍ}Żq(ṗ⌐>⁋8≤M?↵:‡⌊&fǍ≈⁋D5£ɾ|øP₂@ġĿ≤ǔxτ¶_ṙɾ|ȧ.,=»»₃↲»τCĿ

Try it Online!

How?

ka»7ȧ∵ẋǍ}Żq(ṗ⌐>⁋8≤M?↵:‡⌊&fǍ≈⁋D5£ɾ|øP₂@ġĿ≤ǔxτ¶_ṙɾ|ȧ.,=»»₃↲»τCĿ
ka                                                            # Push the lowercase alphabet
  »7ȧ∵ẋǍ}Żq(ṗ⌐>⁋8≤M?↵:‡⌊&fǍ≈⁋D5£ɾ|øP₂@ġĿ≤ǔxτ¶_ṙɾ|ȧ.,=»         # Push compressed integer 454193002670633612531343815167055208136573147142298478503419521655224802790872780438775790455172058745698867697958481400
                                                     »₃↲»     # Push compressed integer 42802
                                                         τ    # Convert the big integer to that custom base as a list: [7424, 665, 7428, 7429, 7431, 42800, 610, 668, 618, 7434, 7435, 671, 7437, 628, 7439, 7448, 491, 640, 42801, 7451, 7452, 7456, 7457, 120, 655, 7458]
                                                          C   # Convert it from character codes to characters
                                                           Ŀ  # Transliterate the implicit input from the lowercase alphabet to that
\$\endgroup\$
3
  • 1
    \$\begingroup\$ You can use the U flag to decode strings from the Vyxal encoding as UTF-8 which might allow for a golfier decoder \$\endgroup\$
    – emanresu A
    Sep 9, 2022 at 5:10
  • 1
    \$\begingroup\$ @emanresuA Good idea, that saved one byte \$\endgroup\$
    – naffetS
    Sep 9, 2022 at 17:57
  • 1
    \$\begingroup\$ Also the U flag implicitly includes D. \$\endgroup\$
    – emanresu A
    Sep 9, 2022 at 19:07
1
\$\begingroup\$

Lua, 160 bytes

function c(a)
return a:lower():gsub("%w",function(d)b=a.byte(d)-96;return("ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ"):sub(b,b)end)end
\$\endgroup\$
1
  • \$\begingroup\$ I'm not a Lua programmer, but i guess return("ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ") can be transformed to return"ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ" to save 2 bytes \$\endgroup\$ Jun 14, 2016 at 10:20
1
\$\begingroup\$

Jelly, 65 bytes

“⁾ḋḷ?D8=ƙʂȤ£²^ĖẸI)¡e[µ°⁾ṢJ*MĠɓ¤Ḃġ⁽vEEɲạ®G{(ŀ³⁻¹ƭTẸⱮ’ṃ“ȥ3’Ọ
Øaż¢Fy

Attempt This Online!

“⁾ḋḷ?D8=ƙʂȤ£²^ĖẸI)¡e[µ°⁾ṢJ*MĠɓ¤Ḃġ⁽vEEɲạ®G{(ŀ³⁻¹ƭTẸⱮ’ṃ“ȥ3’Ọ : Link 1

“⁾ḋḷ?D8=ƙʂȤ£²^ĖẸI)¡e[µ°⁾ṢJ*MĠɓ¤Ḃġ⁽vEEɲạ®G{(ŀ³⁻¹ƭTẸⱮ’       : Compressed integer for 454193002670633612531343815167055208136573147142298478503419521655224802790872780438775790455172058745698867697958481400

                                                     “ȥ3’  : Compressed integer for 42802

                                                    ṃ      : Base decompression; convert x to base length(y) then index into y; results in character codes

                                                         Ọ : Cast to characters
Øaż¢Fy : Main Link
Øa     : Lowercase alphabet
   ¢   : Last link as a nilad
  ż    : Zip; interleave x and y
    F  : Flatten list
     y : Translate the elements of y according to the mapping in x; change the characters 

Integers used to get the character codes borrowed from Steffan's Vyxal Answer

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.