29
\$\begingroup\$

Task

Your task is to take a character in:

AÁÀÃÂBCÇDEÉÊFGHIÍJKLMNOÕÓÔPQRSTUÚVWXYZaáàãâbcçdeéêfghiíjklmnoõóôpqrstuúvwxyz

and turn it into a characters in:

AAAAABCCDEEEFGHIIJKLMNOOOOPQRSTUUVWXYZaaaaabccdeeefghiijklmnoooopqrstuuvwxyz

by the obvious operation: dropping the accents in the letters.

Input

A character in any sensible format, including but not limited to:

  • A string with only one character;
  • A unicode codepoint.

Output

The transformed char in any sensible format, which includes:

  • A string with only one char;
  • A unicode codepoint.

Test cases

'A' -> 'A'
'Á' -> 'A'
'À' -> 'A'
'Ã' -> 'A'
'Â' -> 'A'
'B' -> 'B'
'C' -> 'C'
'Ç' -> 'C'
'D' -> 'D'
'E' -> 'E'
'É' -> 'E'
'Ê' -> 'E'
'F' -> 'F'
'G' -> 'G'
'H' -> 'H'
'I' -> 'I'
'Í' -> 'I'
'J' -> 'J'
'K' -> 'K'
'L' -> 'L'
'M' -> 'M'
'N' -> 'N'
'O' -> 'O'
'Õ' -> 'O'
'Ó' -> 'O'
'Ô' -> 'O'
'P' -> 'P'
'Q' -> 'Q'
'R' -> 'R'
'S' -> 'S'
'T' -> 'T'
'U' -> 'U'
'Ú' -> 'U'
'V' -> 'V'
'W' -> 'W'
'X' -> 'X'
'Y' -> 'Y'
'Z' -> 'Z'
'a' -> 'a'
'á' -> 'a'
'à' -> 'a'
'ã' -> 'a'
'â' -> 'a'
'b' -> 'b'
'c' -> 'c'
'ç' -> 'c'
'd' -> 'd'
'e' -> 'e'
'é' -> 'e'
'ê' -> 'e'
'f' -> 'f'
'g' -> 'g'
'h' -> 'h'
'i' -> 'i'
'í' -> 'i'
'j' -> 'j'
'k' -> 'k'
'l' -> 'l'
'm' -> 'm'
'n' -> 'n'
'o' -> 'o'
'õ' -> 'o'
'ó' -> 'o'
'ô' -> 'o'
'p' -> 'p'
'q' -> 'q'
'r' -> 'r'
's' -> 's'
't' -> 't'
'u' -> 'u'
'ú' -> 'u'
'v' -> 'v'
'w' -> 'w'
'x' -> 'x'
'y' -> 'y'
'z' -> 'z'

You can check here for a Python reference implementation without regexes.


This is so shortest submission in bytes, wins! If you liked this challenge, consider upvoting it... And happy golfing!

\$\endgroup\$
8
  • \$\begingroup\$ @a'_' ç isn't a vowel, so it boils down to accented vowels and ç \$\endgroup\$
    – RGS
    Mar 5, 2020 at 9:53
  • \$\begingroup\$ @a'_' I think the input section is clear enough. "A character in any sensible format" \$\endgroup\$
    – RGS
    Mar 5, 2020 at 11:33
  • 1
    \$\begingroup\$ Āåčşğ and such omitted intentionally? \$\endgroup\$
    – WGroleau
    Mar 5, 2020 at 18:39
  • 18
    \$\begingroup\$ So it's basically a Z̵̡̛̘͈̠̼̭̮̝̳͖̲̝͔̟̏̾́̄̈̒͆͛̆̑ä̶̮̠̖̟̮̭̀l̴͇̹̺̬̎͆g̷̨̧̗͍̲̤͔͊̈́̈́͋̉͗͐̈́̄̅̌͠͝͝͝ơ̸̡̲̳͓͙̗̰͇̦̂͐̒̈́̈̇͒ cleaner? \$\endgroup\$ Mar 5, 2020 at 21:04
  • 3
    \$\begingroup\$ Is doing web requests allowed? I already know a website that does this: lingojam.com/GlitchTextGenerator ;) Edit: It doesn't actually work for this challenge, just for the "Zalgo" above. But it wasn't really meant seriously anyway. \$\endgroup\$ Mar 6, 2020 at 20:37

31 Answers 31

27
\$\begingroup\$

JavaScript (Node.js), 39 bytes

A port of my CP-1610 answer.

I/O format: a Unicode code point.

n=>n>>7?Buffer("ACEIOOU")[n/4&7]^n&32:n

Try it online!


JavaScript (Node.js), 44 bytes

I/O format: a string with only one character.

c=>'oeaUICuic?OEA'[Buffer(c)[1]*13%59%13]||c

Try it online!

How?

When passed into Buffer(), the accented letters used in the challenge are turned into two bytes \$(b_0,b_1)\$, corresponding to their UTF-8 encoding. The non-accented letters are turned into a single byte \$b_0\$ corresponding to their regular ASCII code (or 1-byte UTF-8 encoding).

Examples:

Buffer('À') // --> <Buffer c3 80>
Buffer('B') // --> <Buffer 42>

Try it online!

We use the following formula to convert the 2nd byte of accented letters to an index \$n\$ into a 13-character lookup string of non-accented letters:

$$n=((b_1\times13)\bmod 59)\bmod 13$$

This results in NaN for non-accented letters, which are simply left unchanged.

  c  |   UTF-8    | 2nd byte | * 13 | mod 59 | mod 13 | output
-----+------------+----------+------+--------+--------+--------
 'À' | 0xC3, 0x80 |    128   | 1664 |   12   |   12   |  'A'
 'Á' | 0xC3, 0x81 |    129   | 1677 |   25   |   12   |  'A'
 'Â' | 0xC3, 0x82 |    130   | 1690 |   38   |   12   |  'A'
 'Ã' | 0xC3, 0x83 |    131   | 1703 |   51   |   12   |  'A'
 'Ç' | 0xC3, 0x87 |    135   | 1755 |   44   |    5   |  'C'
 'É' | 0xC3, 0x89 |    137   | 1781 |   11   |   11   |  'E'
 'Ê' | 0xC3, 0x8A |    138   | 1794 |   24   |   11   |  'E'
 'Í' | 0xC3, 0x8D |    141   | 1833 |    4   |    4   |  'I'
 'Ó' | 0xC3, 0x93 |    147   | 1911 |   23   |   10   |  'O'
 'Ô' | 0xC3, 0x94 |    148   | 1924 |   36   |   10   |  'O'
 'Õ' | 0xC3, 0x95 |    149   | 1937 |   49   |   10   |  'O'
 'Ú' | 0xC3, 0x9A |    154   | 2002 |   55   |    3   |  'U'
 'à' | 0xC3, 0xA0 |    160   | 2080 |   15   |    2   |  'a'
 'á' | 0xC3, 0xA1 |    161   | 2093 |   28   |    2   |  'a'
 'â' | 0xC3, 0xA2 |    162   | 2106 |   41   |    2   |  'a'
 'ã' | 0xC3, 0xA3 |    163   | 2119 |   54   |    2   |  'a'
 'ç' | 0xC3, 0xA7 |    167   | 2171 |   47   |    8   |  'c'
 'é' | 0xC3, 0xA9 |    169   | 2197 |   14   |    1   |  'e'
 'ê' | 0xC3, 0xAA |    170   | 2210 |   27   |    1   |  'e'
 'í' | 0xC3, 0xAD |    173   | 2249 |    7   |    7   |  'i'
 'ó' | 0xC3, 0xB3 |    179   | 2327 |   26   |    0   |  'o'
 'ô' | 0xC3, 0xB4 |    180   | 2340 |   39   |    0   |  'o'
 'õ' | 0xC3, 0xB5 |    181   | 2353 |   52   |    0   |  'o'
 'ú' | 0xC3, 0xBA |    186   | 2418 |   58   |    6   |  'u'
\$\endgroup\$
20
\$\begingroup\$

PHP, 42 39 34 bytes

<?=iconv('','us//TRANSLIT',$argn);

-3 Bytes thanks to @Neil

Try it online!

\$\endgroup\$
1
  • 7
    \$\begingroup\$ Welcome to Code Golf! This is a nice first answer. \$\endgroup\$
    – Arnauld
    Mar 5, 2020 at 11:15
11
\$\begingroup\$

JavaScript (Node.js), 22 bytes

s=>s.normalize`NFD`[0]

Try it online!

save 2 bytes, thanks Arnauld.

\$\endgroup\$
0
11
\$\begingroup\$

T-SQL, 35 33 bytes

SELECT v COLLATE Greek_BIN FROM t

Input is taken from a pre-existing table t with CHAR(1) column v, per our IO standards.

This code simply displays the input after converting it to a different SQL collation.

SQL collations define sorting rules as well as case and accent sensitivity properties for SQL text data. They can even define the valid code page, which is how this particular trick works. Code page 1253 ("Greek - ANSI") doesn't include any of the accented characters in the question, so the collation conversion maps each to its non-accented version.

I based my version on this StackOverflow answer, which uses a more standard collation with a much longer name: SQL_Latin1_General_CP1253_CI_AI.

EDIT: Saved 2 bytes by replacing Greek_CS_AI with Greek_BIN. Both use code page 1253, which is really the part that matters, not the "accent insensitive" property.

SQL supports nearly 4000 collations, run this on your SQL server to return all collations that use code page 1253, ordered by the shortest name:

SELECT name, bytes=len(name), description, codepage=COLLATIONPROPERTY(name, 'CodePage')
FROM fn_helpcollations()
WHERE COLLATIONPROPERTY(name, 'CodePage') = 1253
ORDER BY len(name)

It is possible to replace characters individually, but that is much longer (79 Bytes):

SELECT TRANSLATE(v,'ÁÀÃÂÇÉÊÍÕÓÔÚáàãâçéêíõóôú','AAAACEEIOOOUaaaaceeiooou')FROM t
\$\endgroup\$
10
\$\begingroup\$

05AB1E (legacy), 24 23 22 bytes

žy›i•M¦>á•₂вI28&èI96&+

-2 bytes thanks to @Grimmy.

I/O as unicode codepoint.

Try it online.

Explanation:

žy›i             # If the (implicit) input-codepoint is larger than 128:
    •M¦>á•       #  Push compressed integer 3755486693
          ₂в     #  Convert it to base-26 as list: [1,5,15,21,3,9,15]
    I28&         #  Push the input-codepoint, and bitwise-AND it with 28
        è        #  Index it into the list (0-based and with wraparound)
         I96&    #  Push the input-codepoint, and bitwise-AND it with 96
             +   #  And add it to the indexed value
                 #  (after which it is output implicitly as result)
                 # (implicit else:)
                 #  (take the implicit input-codepoint as implicit output)

See this 05AB1E tip of mine (sections How to compress large integers? and How to compress integer lists?) to understand why •M¦>á• is 3755486693 and •M¦>á•₂в is [1,5,15,21,3,9,15].

\$\endgroup\$
0
10
\$\begingroup\$

iconv, 21 20 bytes

iconv -tus//TRANSLIT

Try it online! Link includes test suite. Edit: Thanks to @NahuelFouilleul for a 1 byte saving. Port of @Oxgeba's PHP answer, but I used us as a synonym for ASCII to save a further 3 bytes.

\$\endgroup\$
2
  • \$\begingroup\$ Just posted this as a bash answer only to see you've done it already and better! +1 :-) \$\endgroup\$
    – Noodle9
    Mar 5, 2020 at 12:52
  • \$\begingroup\$ could save one byte removing the space after -t \$\endgroup\$ Mar 5, 2020 at 18:34
9
\$\begingroup\$

Python 3, 61 56 bytes

lambda s:s[s>'z':]or'EIOOUaaceioou_AAC'[ord(s)*17%67%17]

Try it online!


Python 3.8 (pre-release), 76 74 bytes

lambda s:(n:=name(s)*2)[21::-2].title()['SM'in n]
from unicodedata import*

Try it online!

Examples

s                               'À'
name(s)                         'LATIN CAPITAL LETTER A WITH GRAVE'
name(s)*2                       'LATIN CAPITAL LETTER A WITH GRAVELATIN CAPITAL LETTER A WITH GRAVE'
                                  ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
(name(s)*2)[21::-2]             'ARTE AIA IA'
(name(s)*2)[21::-2].title()     'Arte Aia Ia'
'SM' in name(s)*2 ==            False == 0
(name(s)*2)[21::-2].title()[0]  'A'

s                               'À'
name(s)                         'LATIN SMALL LETTER C WITH CEDILLA'
name(s)*2                       'LATIN SMALL LETTER C WITH CEDILLALATIN SMALL LETTER C WITH CEDILLA'
                                  ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
(name(s)*2)[21::-2]             'WCRTE LM IA'
(name(s)*2)[21::-2].title()     'Wcrte Lm Ia'
'SM' in name(s)*2               True == 1
(name(s)*2)[21::-2].title()[1]  'c'

Python 3, 55 bytes

Basically the same as tsh's JavaScript answer.

lambda s:normalize('NFD',s)[0]
from unicodedata import*

Try it online!

\$\endgroup\$
0
9
\$\begingroup\$

CP-1610 machine code,  27 26 22  21 DECLEs1 ≈ 27 bytes

As per the exception described in this meta answer, the exact score is 26.25 bytes (210 bits)

A routine taking a Unicode code point in R0 and returning another code point in the same register.

081             |         MOVR    R0,     R1
045             |         SWAP    R1,     2
203 009         |         BPL     @@rtn
065             |         SLR     R1,     2
3B9 007         |         ANDI    #7,     R1
0F9             |         ADDR    R7,     R1
2F9 006         |         ADDI    #6,     R1
3B8 020         |         ANDI    #32,    R0
3C8             |         XOR@    R1,     R0
0AF             | @@rtn   JR      R5
041 043 045 049 |         STRING  "ACEIOOU"
04F 04F 055     |

How?

All the special characters we're interested in are located in the 0xC0-0xFF Unicode range.

full range        relevant letters  replacement

   | 0123 4567       | 0123 4567       | 0123 4567
---+----------    ---+----------    ---+----------
C0 | ÀÁÂÃ ÄÅÆÇ    C0 | ÀÁÂÃ ---Ç    C0 | AAAA ---C
C8 | ÈÉÊË ÌÍÎÏ    C8 | -ÉÊ- -Í--    C8 | -EE- -I--
D0 | ÐÑÒÓ ÔÕÖ×    D0 | ---Ó ÔÕ--    D0 | ---O OO--
D8 | ØÙÚÛ ÜÝÞß    D8 | --Ú- ----    D8 | --U- ----
E0 | àáâã äåæç    E0 | àáâã ---ç    E0 | aaaa ---c
E8 | èéêë ìíîï    E8 | -éê- -í--    E8 | -ee- -i--
F0 | ðñòó ôõö÷    F0 | ---ó ôõ--    F0 | ---o oo--
F8 | øùúû üýþÿ    F8 | --ú- ----    F8 | --u- ----

As shown in the tables above, each group of \$4\$ accented letters is mapped to a single non-accented letter. So, given a code point \$n\$, we compute the index:

$$i=\left\lfloor\frac{n}{4}\right\rfloor\bmod 8$$

We pick the corresponding letter from the lookup string "ACEIOOU" and then apply the correct case.

Full commented test code

        ROMW    10                ; use 10-bit ROM width
        ORG     $4800             ; map this program at $4800

        ;; ------------------------------------------------------------- ;;
        ;;  main code                                                    ;;
        ;; ------------------------------------------------------------- ;;
main    PROC

        SDBD                      ; set up an interrupt service routine
        MVII    #isr,   R0        ; to do some minimal STIC initialization
        MVO     R0,     $100
        SWAP    R0
        MVO     R0,     $101

        EIS                       ; enable interrupts

        SDBD                      ; R4 = pointer into the test case table
        MVII    #tc,    R4
        MVII    #$200,  R3        ; R3 = backtab pointer
        MVII    #76,    R2        ; R2 = number of test cases

@@loop  MVI@    R4,     R0        ; R0 = character code point
        CALL    conv              ; invoke our routine

        SUBI    #32,    R0        ; turn the result into an Intellivision card
        SLL     R0,     2
        SLL     R0
        MVO@    R0,     R3        ; draw it
        INCR    R3                ; increment the backtab pointer

        DECR    R2                ; next test case
        BNEQ    @@loop

        DECR    R7                ; done: loop forever

        ENDP

        ;; ------------------------------------------------------------- ;;
        ;;  test cases                                                   ;;
        ;; ------------------------------------------------------------- ;;
tc      PROC

        DECLE   65   ; A
        DECLE   193  ; Á
        DECLE   192  ; À
        DECLE   195  ; Ã
        DECLE   194  ; Â
        DECLE   66   ; B
        DECLE   67   ; C
        DECLE   199  ; Ç
        DECLE   68   ; D
        DECLE   69   ; E
        DECLE   201  ; É
        DECLE   202  ; Ê
        DECLE   70   ; F
        DECLE   71   ; G
        DECLE   72   ; H
        DECLE   73   ; I
        DECLE   205  ; Í
        DECLE   74   ; J
        DECLE   75   ; K
        DECLE   76   ; L
        DECLE   77   ; M
        DECLE   78   ; N
        DECLE   79   ; O
        DECLE   213  ; Õ
        DECLE   211  ; Ó
        DECLE   212  ; Ô
        DECLE   80   ; P
        DECLE   81   ; Q
        DECLE   82   ; R
        DECLE   83   ; S
        DECLE   84   ; T
        DECLE   85   ; U
        DECLE   218  ; Ú
        DECLE   86   ; V
        DECLE   87   ; W
        DECLE   88   ; X
        DECLE   89   ; Y
        DECLE   90   ; Z
        DECLE   97   ; a
        DECLE   225  ; á
        DECLE   224  ; à
        DECLE   227  ; ã
        DECLE   226  ; â
        DECLE   98   ; b
        DECLE   99   ; c
        DECLE   231  ; ç
        DECLE   100  ; d
        DECLE   101  ; e
        DECLE   233  ; é
        DECLE   234  ; ê
        DECLE   102  ; f
        DECLE   103  ; g
        DECLE   104  ; h
        DECLE   105  ; i
        DECLE   237  ; í
        DECLE   106  ; j
        DECLE   107  ; k
        DECLE   108  ; l
        DECLE   109  ; m
        DECLE   110  ; n
        DECLE   111  ; o
        DECLE   245  ; õ
        DECLE   243  ; ó
        DECLE   244  ; ô
        DECLE   112  ; p
        DECLE   113  ; q
        DECLE   114  ; r
        DECLE   115  ; s
        DECLE   116  ; t
        DECLE   117  ; u
        DECLE   250  ; ú
        DECLE   118  ; v
        DECLE   119  ; w
        DECLE   120  ; x
        DECLE   121  ; y
        DECLE   122  ; z

        ENDP

        ;; ------------------------------------------------------------- ;;
        ;;  ISR                                                          ;;
        ;; ------------------------------------------------------------- ;;
isr     PROC

        MVO     R0,     $0020     ; enable display

        CLRR    R0
        MVO     R0,     $0030     ; no horizontal delay
        MVO     R0,     $0031     ; no vertical delay
        MVO     R0,     $0032     ; no border extension
        MVII    #$D,    R0
        MVO     R0,     $0028     ; light-blue background
        MVO     R0,     $002C     ; light-blue border

        JR      R5                ; return from ISR

        ENDP

        ;; ------------------------------------------------------------- ;;
        ;;  our routine                                                  ;;
        ;; ------------------------------------------------------------- ;;
conv    PROC

        MOVR    R0,     R1        ; copy R0 to R1
        SWAP    R1,     2         ; copy the lower byte of R1 to its upper byte,
                                  ; resulting in a negative word for an accented letter
        BPL     @@rtn             ; return right away if it's a regular ASCII character

        SLR     R1,     2         ; right-shift by 2 positions
        ANDI    #7,     R1        ; isolate the 3 least significant bits
        ADDR    R7,     R1        ; add the address of our lookup string,
        ADDI    #6,     R1        ; computed as PC + 6
        ANDI    #32,    R0        ; isolate the case bit of the original character
        XOR@    R1,     R0        ; XOR it with the non-accented letter

@@rtn   JR      R5                ; return

        STRING  "ACEIOOU"         ; lookup string

        ENDP

Output

output

screenshot from jzIntv


1. A CP-1610 opcode is encoded with a 10-bit value (0x000 to 0x3FF), known as a 'DECLE'.

\$\endgroup\$
7
\$\begingroup\$

C (gcc), 37 bytes

A port of my CP-1610 answer.

I/O format: a Unicode code point.

f(n){n=n>>7?"ACEIOOU"[n/4&7]^n&32:n;}

Try it online!


C (gcc), 45 bytes

I/O format: a Unicode code point.

f(n){n=n>>7?"ooieca?UOOIECAu"[n*15%61%15]:n;}

Try it online!

\$\endgroup\$
5
\$\begingroup\$

Ruby, 41 bytes

->c{c<?~?c:"ACEIOOUxaceioou"[c.ord/4%16]}

Try it online!

\$\endgroup\$
4
\$\begingroup\$

PHP 5.4+, 32 bytes

This uses the htmlentities() function to return the HTML entity for the character.

<?=htmlentities($argn.$argn)[1];

For the "AÁÀÃÂ" (Ä is missing from the list), it returns "A&Aacute;&Agrave;&Atilde;&Acirc;".
Do you see a problem? The character I want is on position 0 or 1.
So, I just duplicate the input. Problem solved!

You can try this on http://sandbox.onlinephpfunctions.com/code/690dbfcff4c6dec4170954333c62b9b472eaaa93

\$\endgroup\$
4
  • \$\begingroup\$ Can you consider adding a TIO link or a screenshot if such a link doesn't work? :D \$\endgroup\$
    – RGS
    Mar 6, 2020 at 17:23
  • \$\begingroup\$ @RGS I've added a link to where you can try it. Just make sure you pick PHP 5.4 or higher. \$\endgroup\$ Mar 6, 2020 at 22:15
  • \$\begingroup\$ thanks a lot! At first the code wasn't working, but then I realized it was because of the arrow you wrote in front of the command argument. Thanks for the link and for the interesting submission. \$\endgroup\$
    – RGS
    Mar 6, 2020 at 22:20
  • \$\begingroup\$ I've updated the link. And thank you. \$\endgroup\$ Mar 6, 2020 at 22:39
3
\$\begingroup\$

Java 8, 85 70 47 39 bytes

c->c>122?"ACEIOOU".charAt(c/4&7)^c&32:c

-46 bytes by creating a port of @Arnauld's C answer, so make sure to upvote him!

Try it online.

Original answer (85 bytes):

import java.text.*;c->(char)Normalizer.normalize(c,Normalizer.Form.NFD).getBytes()[0]

Try it online.

Explanation:

c->                         // Method with character as both parameter and return-type
  c>122?                    //  If the character isn't a regular letter:
   "ACEIOOU".charAt(        //   Get the character in String "ACEIOOU" at index:
     c/4&7)                 //    c integer-divided by 4 and then bitwise-ANDed by 7
    ^c&32                   //   And convert it to lowercase if the input was lowercase
  :                         //  Else (it is a regular letter):
   c                        //   Simply return the input as is

import java.text.*;         // Required import for both Normalizer
c->                         // Method with String as parameter and character as return-type
 (char)                     //  Convert the following byte to a character:
   Normalizer.normalize(c,  //   Normalize the input-String,
     Normalizer.Form.NFD)   //   using canonical decomposition
   .getBytes())             //   Convert that to a byte-array (UTF-8 encoding by default)
     [0]                    //   And only leave the first byte
\$\endgroup\$
0
3
\$\begingroup\$

Perl 6 Raku, 15 14 bytes

*.samemark(~0)

Try it online!

Returns the string with the same marks/accents as the number 0, i.e. remove all marks.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I see Perl has some interesting functions \$\endgroup\$
    – RGS
    Mar 6, 2020 at 0:11
3
\$\begingroup\$

Turing Machine Code, 796 286 bytes

0 * * r 0
0 Á A r 0
0 À A r 0
0 Ã A r 0
0 Â A r 0
0 Ç C r 0
0 É E r 0
0 Ê E r 0
0 Í I r 0
0 Õ O r 0
0 Ó O r 0
0 Ô O r 0
0 Ú U r 0
0 á a r 0
0 à a r 0
0 ã a r 0
0 â a r 0
0 ç c r 0
0 é e r 0
0 ê e r 0
0 í i r 0
0 õ o r 0
0 ó o r 0
0 ô o r 0
0 ú u r 0
0 _ _ * halt

Try it online!

Saved an incredible 510 bytes thanks to @ovs! That might be some kind of record here on Code Golf.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ You can remove all the lines doing no changes and add 0 * * r 0. \$\endgroup\$
    – ovs
    Mar 6, 2020 at 7:42
  • \$\begingroup\$ @ovs, Oustanding spot. Just give me a moment.... \$\endgroup\$
    – ouflak
    Mar 6, 2020 at 8:12
3
\$\begingroup\$

Wolfram Language (Mathematica), 16 bytes

Mathematics is not the only field Mathematica has built-ins for...

RemoveDiacritics

Try it online! (all the characters are in a single string in the link, but it obviously works character-by-character)

Sledgehammer, 4 bytes

⣕⠬⣠⢹

Corresponds to the code RemoveDiacritics@Input[].

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

R, 34 32 bytes

-2 thanks to Giuseppe

iconv(scan(,''),,"us//TRANSLIT")

Try it online!

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

05AB1E, 53 bytes

-1 thanks to Kevin Cruijssen

"áéíõúÁÉÍÕÚàêióuÀÊIÓUãeiôuÃEIÔUâeiouÂEIOUÇç"žÀ4ׄCc«‡

Try it online!

Explanation

"áéíõúÁÉÍÕÚàêióuÀÊIÓUãeiôuÃEIÔUâeiouÂEIOUÇç" A huge lookup table of the unicode characters

žÀ        Push "aeiouAEIOU"
  4×      Repeat it 4 times
    „Cc«  Concatenate "Cc" to the string
        ‡ Transliterate input
```
\$\endgroup\$
1
  • \$\begingroup\$ иJ to × for -1 \$\endgroup\$ Mar 5, 2020 at 10:36
2
\$\begingroup\$

Python 2, 141 bytes

o='';i=input()
for x in'AÁÀÃÂ CÇ EÉÊ IÍ OÕÓÔ UÚ aáàãâ cç eéê ií oõóô uú'.split():
 if i in x:o=x[0]
print(o,i)[o=='']

Try it online!

Just a simple lookup without any imports. If it finds a "special" character it prints the first character in the string where it is found otherwise just prints the input.

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

Perl 6, 30 bytes

{{S/W.+//}(.uniname).uniparse}

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Some quick rearranging for 27 bytes \$\endgroup\$
    – Jo King
    Mar 6, 2020 at 0:19
2
\$\begingroup\$

C (gcc), 61 59 bytes

g(char*w){w=*w+61?*w:"oeaUICuic OEA"[(256+w[1])*13%59%13];}

Try it online!

Uses Arnauld's formula from his JavaScript answer.

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

Bash + Core utilities, 40 32 bytes

iconv -f utf8 -t ascii//TRANSLIT

Try it online!

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

Perl 5 -pC -MUnicode::Normalize=NFD, 17 bytes

$_=NFD$_;s/\pM//g

Try it online!

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

Japt, 23 bytes

A port of Arnauld's JS solution. I/O as codepoints.

Á7?H&U^`a­Å8`u cU/4&7:U

Try it

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

C# (Visual C# Interactive Compiler), 39 bytes

x=>x.Normalize((NormalizationForm)2)[0]

Try it online!

\$\endgroup\$
1
  • 2
    \$\begingroup\$ I don't think the [0] is necessary. \$\endgroup\$ Mar 7, 2020 at 6:27
1
\$\begingroup\$

Retina 0.8.2, 72 bytes (53 characters)

T`À-ÃÇÉÊÍÓ-ÕÚà-ãçéêíúó-õ`AAAAC\E\EI\O\O\OUaaaaceeiu\o

Try it online! Link includes test cases. Explanation: The Transliterate command has some special characters E, O and o, so these need to be quoted. To avoid repetition, the os are processed last as the last character in the replacement string is automatically repeated. The remaining repetition is one byte less than the overhead of the T command; compare this 72-byte 58-character alternative (which also corrupts eth and n with tilde):

T`ÚÀ-Ã`UA
T`Ç-Ê`C\E
T`Í-Õ`I\O
T`úà-ã`ua
T`ç-ê`ce
T`í-õ`i\o
\$\endgroup\$
1
\$\begingroup\$

perl -MText::Unidecode -pC -e, 14 bytes

$_=unidecode$_
\$\endgroup\$
1
  • \$\begingroup\$ Can you please include a TIO link for your solution? Thanks!!! \$\endgroup\$
    – RGS
    Mar 5, 2020 at 21:34
1
\$\begingroup\$

Vyxal, 82 bytes / 53 chars

`áéíõúÁÉÍÕÚàêióuÀÊIÓUãeiôuÃEIÔUâeiouÂEIOUÇç`k∨4*‛Cc+Ŀ

Try it Online!

The bad version, I can't figure out how to port any of the good ones.

\$\endgroup\$
1
  • 3
    \$\begingroup\$ Many of these characters are not in the Vyxal codepage, which means this cannot be encoded using the codepage. You'll have to use UTF-8, where the program takes 82 bytes. \$\endgroup\$
    – ovs
    May 17, 2021 at 10:14
1
\$\begingroup\$

Nim, 45 bytes

import unidecode
echo stdin.readAll.unidecode

Try it online!

\$\endgroup\$
1
\$\begingroup\$

PowerShell Core, 17 bytes

($args|% N* 2)[0]

Try it online!

Inspired by the C# answer, thanks Gymhgy!

Takes the input as a string.

Could be shorten down to 14 bytes using a filter, but I don't think it is allowed?

\$\endgroup\$
1
\$\begingroup\$

Vyxal, 18 bytes

»æ₁s≥»₄τ?28⋏i?96⋏+

Try it Online!

\$\endgroup\$

Your Answer

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

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