[Question]
  [
The famous constructed language [Esperanto](http://en.wikipedia.org/wiki/Esperanto) uses the Latin alphabet (mostly, see the linked wikipedia page for details). However, there are some characters with accents: **ĉ, ĝ, ĥ, ĵ, ŝ, and ŭ**. (C-circumflex, g-circumflex, h-circumflex, j-circumflex, s-circumflex, and u-**breve**.) Naturally, these characters are very hard to type. Even for this question, I had to search in the Unicode selector for the characters. Due to this, a convention using the letter "x" has been developed for electronic use. For example, "cxu" is used for "ĉu". (Note: the letter "x" is not used normally in the Esperanto alphabet."
However, I am a language purist! This \*air quote\* x nonsense is killing me! I need a program to fix this, preferably as short as possible so I can type it into my terminal as fast as possible!
## Challenge
Your mission is to take a string of Esperanto using x-convention and convert it to real Esperanto.
In effect, you have to map:
```
cx: ĉ
gx: ĝ
hx: ĥ
jx: ĵ
sx: ŝ
ux: ŭ
Cx: Ĉ
Gx: Ĝ
Hx: Ĥ
Jx: Ĵ
Sx: Ŝ
Ux: Ŭ
```
All other printable ASCII characters should be accepted and not changed. Unicode would be nice, but not necessary.
Input and output can be in any format reasonable to your language. Good luck!
## Testcases
```
"input" : "output"
_____________
"gxi estas varma" : "ĝi estas varma"
"Cxu sxi sxatas katojn aux hundojn?" : "Ĉu ŝi ŝatas katojn aŭ hundojn?"
"Uxcxsxabcd(hxSx)efg{};" : "Ŭĉŝabcd(ĥŜ)efg{};"
"qwertyuiop" : "qwertyuiop"
" " : " "
"" : ""
"x" : "x"
"xc" : "xc"
"xcx" : "xĉ"
"cxx" : "ĉx"
```
## Scoring
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"). Answers are scored by smallest bytecount in the language's default encoding.
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
```
# Language Name, N bytes
```
where `N` is the size of your submission. If you improve your score, you *can* keep old scores in the headline, by striking them through. For instance:
```
# Ruby, <s>104</s> <s>101</s> 96 bytes
```
If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the *last* number in the header:
```
# Perl, 43 + 2 (-p flag) = 45 bytes
```
You can also make the language name a link which will then show up in the leaderboard snippet:
```
# [><>](http://esolangs.org/wiki/Fish), 121 bytes
```
```
var QUESTION_ID=149292,OVERRIDE_USER=47670;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
```
```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
```
```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```
Good luck, have fun, and feel free to suggest improvements!
## Clarifications:
* You only need to worry about *printable* ASCII characters.
* You only need to output a character that *looks like* the correct output. Yes, this means you can tack the accent onto the standard character.
  
[Answer]
# [QuadR](https://github.com/abrudz/QuadRS), 65 bytes
```
.x
3::⍵M⋄'ĉĝĥĵŝŭĈĜĤĴŜŬ'['cghjsuCGHJSU'⍳⊃⍵M]
```
[Try it online!](https://tio.run/##KyxNTCn6/1@vgsvYyupR71bfR90t6kc6j8w9svTI1qNzj6490nFkzpElR7YcnXN0jXq0enJ6RlZxqbO7h1dwqPqj3s2PuppBumL//0@vyFRILS5JLFYoSyzKTeRyrihVKAaKFVckggSzE0vys/IUEksrFDJK81Lys@y5QiuSK4CySckpGhkVwRWaqWnp1bXWXEqF5alFJZWlmfkFSlxKCkAMRBUgnAwmQMzkigolAA "QuadR – Try It Online")
`.x` replace any char followed by "x" with
`3::⍵M` upon indexing error, return the match unmodified  
`⋄` now try:  
 `'ĉĝĥĵŝŭĈĜĤĴŜŬ'[`…`]` index into this string with  
  `⍵M` the match's  
  `⊃` first letter's  
  `⍳` index  
  `'cghjsuCGHJSU'` in this string
This is equivalent to the Dyalog APL tacit function:
```
'.x'⎕R{3::⍵.Match⋄'ĉĝĥĵŝŭĈĜĤĴŜŬ'['cghjsuCGHJSU'⍳⊃⍵.Match]}
```
[Answer]
# [Retina](https://github.com/m-ender/retina), 27 bytes
```
iT`x`̂`[cghjs]x
iT`x`̆`ux
```
[Try it online!](https://tio.run/##JclNDkExFIbh@VnFGbIGAwNLwEgkPXqrP6Lltr0@ERMDq7Onqkje0fOOpvgorfmNgvq81E5bF/Ie9Ie3qmjNwrPJRTJPMp6FVqicu2XID09SUogsFexqHFJY0hYa/R70MHNYY26O9vFc0PVmxnKvPl2IiUDQPZAGvg "Retina – Try It Online")
This program is composed by two transliterations. Due to having combining characters in the code this doesn't render too well, the first line should actually look similar to `iT`x`^`[cghjs]x`, where `^` stands for the circumflex accent combining character. What this is saying is that it should `T`ransliterate (`i`gnoring case) all the `x`s in the input into a `^`, whenever they are following any letter in `[cghjs]`.
---
Note: TIO incorrectly measures this code as 25 bytes. Actually, this Retina program uses UTF-8 encoding (other programs can use UTF-32 or ISO 8859-1) and the two combining characters present cost 2 bytes each.
[Answer]
# C, ~~173~~ 154 bytes
*Thanks to @Colera Su for saving 17 bytes!*
```
p,c,i;f(char*s){for(char*l="cghjsuCGHJSU";p=*s;~c&&putchar(p))for(c=*++s,i=0;c=='x'&&l[i];++i)l[i]-p||write(1,"ĉĝĥĵŝŭĈĜĤĴŜŬ"+i*2,2,c=-1,++s);}
```
[Try it online!](https://tio.run/##bY69TsMwFEb3PoXlIbUTR6JdLYuhA4i16oQYzG1@HNokxAk1SssM79BusMFG38B5rpCA2HynT@ee7@pCmAD0fcmAKR4TSGXla9rGRfWXNwJDkma6WVxd3yxXmJfC1/wFPK9s6tEgJaW/tvCDQDMlLjgIMTVTz9vcqjseBIqOISz3@12l6ojMGLZv9mQ/7Lk7dV/21R7tu/3ujt0nDpQ/Z3MGIpyx4Rzlh17lNdpKlRM6aSdomJjgxCgU6Vpq9CSrrcSUD99ogofwryxMg/SgaSNH70HWRZYj2RiUNvm6yC5dpZUBMxTuYU1SszQ0ipP2wF3m4y6q6udGFaVri1zQxYwTgps6ZTAjnhz6Hw)
**Explanation:**
```
p,c,i;
f(char*s)
{
    // The outer loop and an array of characters that are modified by a trailing 'x'.
    // The array/string is used for getting the index for the accented character later.
    for (char*l="cghjsuCGHJSU";
                                // Store the current character of the input string in 'p'.
                                // If it is '\0', the loop terminates.
                                p=*s;
                                      // The last statement in the loop.
                                      // If 'c==-1', it outputs the char stored in 'p'. 
                                      ~c&&putchar(p))
        // Store the character following 'p' in 'c' and increment the string pointer.
        for(c=*++s, i=0;
                        // If 'c' is not the letter 'x', the inner loop terminates
                        // immediately. Otherwise it loops through the characters of
                        // string 'l'.
                        c=='x'&&l[i]; ++i)
            // If the character stored in 'p' is found inside the string 'l'...
            l[i]-p ||
                      // ...then print the accented character corresponding to 'p'.
                      // 'i' is the index of 'p' in 'l', and, because the characters
                      // with accents are two bytes each, the index is multiplied by 2.
                      write(1,"ĉĝĥĵŝŭĈĜĤĴŜŬ"+i*2,2,
                      // Finally set 'c' to -1 so that the non-accented character doesn't
                      // get printed too, and increment the string pointer so that the
                      // letter 'x' doesn't get printed either.
                                                    c=-1, ++s);
}
```
[Answer]
# [Python 3](https://docs.python.org/3/), 81 bytes
```
lambda s,T="cĉgĝhĥjĵsŝuŭ":eval("s"+".replace('%sx',%r)"*12%(*T+T.upper(),))
```
[Try it online!](https://tio.run/##XcpNDsFAGMbxvVNMJmnMVCPBjlg5gtrZvKbTL9WO@eAVcQCHsLS0dIM6V7GRjOXvef7qZPOmnnTpfN1VsNskQEwUz6lor1l7y9t72T7N6@ZeDzqVB6gYNXRAh1qqCoRk/cBgPwo0p@FoHLAwHsRDp5TUjEecd0oXtWUpoxkWRBoLhhxA74By3vt9C3TEfH6D8A22YJuyJuCQ5K5OmtKLVyjwE25EwnJcIpdpdr7MvGR/lNqeXNEobyaePKAv8Uf/Fvh19wY "Python 3 – Try It Online")
Generates and evaluates the string: 
```
s.replace('cx','ĉ').replace('gx','ĝ').replace('hx','ĥ').replace('jx','ĵ').replace('sx','ŝ').replace('ux','ŭ').replace('Cx','Ĉ').replace('Gx','Ĝ').replace('Hx','Ĥ').replace('Jx','Ĵ').replace('Sx','Ŝ').replace('Ux','Ŭ')
```
*Erik the Outgolfer saved a byte.*
[Answer]
# [///](https://esolangs.org/wiki////), 75 bytes
```
/,/\/\///>/x\,/c>ĉ,g>ĝ,h>ĥ,j>ĵ,s>ŝ,u>ŭ,C>Ĉ,G>Ĝ,H>Ĥ,J>Ĵ,S>Ŝ,U>Ŭ/
```
Note: Because the OP request all printable characters must be processed, my "special characters" chosen must not be printable. So I chosen tab and newline instead of , which does not change my bytecount or code functionality. The code would look like:
```
/
/\/\/// /x\
/c  ĉ
g   ĝ
h   ĥ
j   ĵ
s   ŝ
u   ŭ
C   Ĉ
G   Ĝ
H   Ĥ
J   Ĵ
S   Ŝ
U   Ŭ/
```
However that requires the input must not contains tab or newlines.
[Try it online!](https://tio.run/##VYyxTsMwEIb3PIXlCaSTvIN0DB1ArFW3Ssi4IUmhSaljOITYm3dINrq1G7zB@bmC4wBqz8N9/3//b/ukbZ7avleg5uEphYrmoAxyAxlyBznyDpbI32DRd@DQH2CCvIVr5BZukD/hFvkLpuhbmKHfq14W5drVUlwIWbl6wOTueBKZUSFSW2srXvRmpWOUu1MvkRNywoakJT3Yj7qulqXQjkTuykW1vBp7Wyd86PruJOUP/6lEzshQ@OXeLM5ymtJ5@pC9f1zGut9zE6rDiXe@/Tsl8vk13dRvrqjWMXckEymiJQJFCJsi0EBmRBP51@cmKEOj4oZk/wM "/// – Try It Online")
Because `///` can't take input, you should put the input after the code.
Pretty straightforward. I guess it can't be shorter because `///` need special handling of each character.
Explanation:
```
/,/\/\//       Replace all `,` in the code by `//`
               (two slashes are represented as two backslash-ed slashes)
/>/x\,         (in original code) becomes
/>/x\//        (because `,` is replaced by `//`) - replace all occurence of 
               `>` by `x/`.
/cx/ĉ//gx/ĝ//hx/ĥ//jx/ĵ//sx/ŝ//ux/ŭ//Cx/Ĉ//Gx/Ĝ//Hx/Ĥ//Jx/Ĵ//Sx/Ŝ//Ux/Ŭ/
               ^ The remaining part of the code should look like this.
               Straightforward replacement.
```
[Answer]
# [Python 3](https://docs.python.org/3/), 95 bytes
```
f=lambda x,v="cĉgĝhĥjĵsŝuŭCĈGĜHĤJĴSŜUŬ":v and f(x.replace(v[0]+"x",v[1]),v[2:])or x
```
[Try it online!](https://tio.run/##XYo7TgMxFEV7VvHkyhYR4tMFpUoBoo1SRVO8eP4k9uAfL0L0sIekgw462IFnXZNJg2SaK517TrdztVY3w1DONrhd5wg0CTMm43sVD3X8bOOv7Q@@/57Ht7u4v48fD/Fn0e@X/RebBkCVQ8npwhTdBmXBw@oyO2fEJmF1lYlxr6eZ0AZo6EyjHC85q6iBwjq0ENBskQlx9ufm5MGO3hKegkd0ulWAnqD2KtdtEi9J0hiuZc5rWpAoyurl9TZJnp4L43a@0V1yQ0IJUEryH6Za0omHIw "Python 3 – Try It Online")
-10 bytes thanks to WhatToDo  
-1 byte thanks to Colera Su
[Answer]
# [Retina](https://github.com/m-ender/retina), 55 bytes
```
iT`CG\HJSUcg\hjsux`ĈĜĤĴŜŬĉĝĥĵŝŭ_`[cghjsux]x
```
[Try it online!](https://tio.run/##HYoxEsFAFED7f4otOYNCkYLRRiqMrM3abIyE7C7fGD13SDo6Om7w91wrzLzqvVdLq0segp6m0Wg@nsSJUPO8MA5TulJDd3r7xj/pRi096ONb/1qmM6H@ywJDUKiZNJYbduD1lkOEjpnOGeQ/ueG2KkrGHbLclVlVDCFBgV1diayXY4x9uVbnywD2R1nbk9PVDhgAAooOBIH4BQ "Retina – Try It Online") Non-combining approach. Bytes could be saved if not for the standalone `x` test cases.
[Answer]
# [Perl 5](https://www.perl.org/), 101 + 1 (`-p`) = 102 bytes
```
%k=qw/c ĉ g ĝ h ĥ j ĵ s ŝ u ŭ C Ĉ G Ĝ H Ĥ J Ĵ S Ŝ U Ŭ/;$"=join"|",keys%k;s/($")x/$k{$1}/g
```
[Try it online!](https://tio.run/##DcPBCoIwAAbgV/kRhYJsevAk0sFDEXSKHkBK1C02a44W1b3eQW91q1u9wXytVh98db7fRtZ6LNkdyBrmhgKmQwnzAIX5QKLvoNC/kMJcMYVpMYO5Yw7zxhJ9ixX6J4ldJ6Gi4s7ZGbH8KD0WSzJwnaEmLju54YUU1qZaQerqP2syCZY1gnJkSqNUfCPo5CvqphJcWn8RjYMwsH79Aw "Perl 5 – Try It Online")
[Answer]
# JavaScript (ES6), 92 bytes
```
s=>[..."cghjsuCGHJSU"].reduce((a,v,i)=>a.split(v+"x").join("ĉĝĥĵŝŭĈĜĤĴŜŬ"[i]),s)
```
[Try it online!](https://tio.run/##dY2xTsMwFEX3foXlyVGLs4Nahg4g1qpTqZBx3NShxCG2gxFib/6h2ejWbvAH9nelyQBqE/lNT@@ee15CCiJpzjN1lYqI1atxLceTBcYY0nidSD29u3@YzeES5yzSlCFERsWIB@MJwTLbcIWKITQwwIngKYK2tJXd219XuaPd2p39tj9u5w5wwZfBSAZ1GEKeZlpBcA2g0KpdB2H4dD4DKlIpNgxvRIzgI4RgCFYIxoYDJhWRoCD5K2mvbRgEYdjKbHUZeyxTo4FsTNKQln0hSiQpINqAtU4jkdz2vFsNXON21UXBHf8Lnk9zQ03z5ZlGaG1mJmCr@PPrpqt3B1s26paye7f7ozzOt3eWqw/NRdb1nCWeLuhWgI/sgj7OdEHjJWkPpX6277Wlj6amR9vSwPoE "JavaScript (Node.js) – Try It Online")
Used split-join method recommended in [here](https://stackoverflow.com/questions/1144783/how-to-replace-all-occurrences-of-a-string-in-javascript) to reduce byte counts because the `new RegExp(/*blah*/)` constructor took up too many bytes.
Comparison:
```
Original: a.replace(new RegExp(v+"x", "g"), "ĉĝĥĵŝŭĈĜĤĴŜŬ"[i])
New     : a.split(v+"x").join("ĉĝĥĵŝŭĈĜĤĴŜŬ"[i])
```
[Shorter, combining accent approach (63 bytes), but with some artifacts visible.](https://tio.run/##dY0/TsMwGEf3nuKTxZCIUouVqjBwBMQECBnH@Ucah9guH0IsTETiCHRkg1vEG3dK44EqTWRPlt/7PedswxSvs0qflDISXbzq1OpcLWpRFYyLgAY3PElzdRciTbI5gb/3o1MSDrjZk09Hlh2lJCsrowmcAZFGu@uM0vvhmXFZKlmIRSGTgNwSAscQByTBDITSTMGG1WvmXh0MQ0pdrN0eYk/lEg2ovqSQOfeRaZmXwAxCaspI5heT7ocB27ft9mBgf/cDz0/XyLH/5YFHQYpXGIo4eX1bjvP2p236tLPab/v1b3maT8@i1i8mk9W4MyCeLYwn4DPHos/DsYhek09U7nen3bbx2Rwndtsg6XY)
```
s=>s.replace(/([cghjs])x/gi," ̂$1").replace(/(u)x/gi," ̌$1");
```
Footnote: I'm claiming my answer 92 bytes because the 63-byte solution has artifacts that may affect the output.
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 57 bytes
Anonymous tacit function. Usages:
1. Prefix function to string. This transliterates the string.
2. Prefix function to list of strings. This transliterates the strings.
3. Infix function with input file tie number as right argument and output file tie number as left argument. This populates the output file with the transliterated content of the input file.
`('cghjsuCGHJSU',¨'x')⎕R(,¨'ĉĝĥĵŝŭĈĜĤĴŜŬ')`
`(`…`)⎕R(`…`)` PCRE **R**eplace
`'cghjsuCGHJSU'` these letters
`,¨'x'` each followed by an x
 … with…
`,¨'ĉĝĥĵŝŭĈĜĤĴŜŬ'` each of these letters as strings
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///X0M9OT0jq7jU2d3DKzhUXefQCvUKdc1HfVODNEDsI51H5h5ZemTr0blH1x7pODLnyJIjW47OObpGXfP//zQF9fSKTIXU4pLEYoWyxKLcRHUuoJhzRalCMVC8uCIRJJGdWJKflaeQWFqhkFGal5KfZQ9WFVqRXAFUkZScopFREVyhmZqWXl1rDZZSKixPLSqpLM3ML1CCCChAaShVAaOT4QyYUHIFkAUA "APL (Dyalog Unicode) – Try It Online")
[Answer]
# [J](http://jsoftware.com/), 64 63 bytes
```
rplc((_2]\'ĉĝĥĵŝŭĈĜĤĴŜŬ');~"1'cghjsuCGHJSU',.'x')"0
```
How it works:
With `_2]\` I rearrange the string 'ĉĝĥĵŝŭĈĜĤĴŜŬ' into a 12-row column in order to fit the shape of the other string.
`,.` adds 'x' to each character of the 'cghjsuCGHJSU' string and makes a 12 row by 2 columns array
`;~"1'` makes a list of boxed pairs of the above, "1 - rank 1 - apply to each row.
```
┌──┬──┐
│cx│ĉ │
├──┼──┤
│gx│ĝ │
├──┼──┤
│hx│ĥ │
├──┼──┤
│jx│ĵ │
├──┼──┤
│sx│ŝ │
├──┼──┤
│ux│ŭ │
├──┼──┤
│Cx│Ĉ │
├──┼──┤
│Gx│Ĝ │
├──┼──┤
│Hx│Ĥ │
├──┼──┤
│Jx│Ĵ │
├──┼──┤
│Sx│Ŝ │
├──┼──┤
│Ux│Ŭ │
└──┴──┘
```
`rplc` uses these boxed items to replace each occurrence of the left boxed item from a pair with the right one. 
[Try it online!](https://tio.run/##VYq9joJAFEZ7nuKG5kJiCFpqjAWFxtbYacw4MiD@oAyj1xi3Xt9BO7dbO32D4bkQGzN25/vOSUoh2x740AS/zDZL7jiTxniE@qyv@k8/i2tx17/6om/6UVyKf3RbP3YdeRQnUgXdXn8wxJqHhK7tl65le4Ci7SHU4NQEIS0r5HEKAjCiOYQyZxJ2LFsxhI8JSIGsrCT21guWp8kamCKI1XqWJh2jHRKnqpvymRPTgNxQRMdTywi2@zDLD2qebowTDDaQTOZfw1ScqlW@AA "J – Try It Online")
[Answer]
# [Befunge](https://esolangs.org/wiki/Befunge), 2x48 +1 = 99 bytes
```
>~:1+!#@_:"x"-v>$ 11p0"cghjsuCGHJSU"1\ >\31p11g-v
^ # #, : ++$\ _^#1"x"0*4!-"u"g11*"ʊ"!\_^#!:\*g13<
```
[Try It Out](http://www.quirkster.com/iano/js/befunge.html) (TIO is super weird about Befunge and I couldn't get any of my solutions to work on it)
### How it works
```
>~:1+!@_
```
Gets input and checks if it's the end. End program if it is.
```
          "x"-v>
^ # #, : ++$\ _^
```
Checks if the character is an "x". If not, keep a copy of the character and print it.
```
               >$ 11p0"cghjsuCGHJSU"1\
```
Store the last character at (1,1). Puts all the characters to check into the stack.
```
                                       >\31p11g-v
                                      _^#!:\*g13<
```
Compare the last character against all the values in the stack.
```
                 1"x"0*4!-"u"g11*"ʊ"!\
```
Multiply the check (0 or 1) by ʊ (unicode value 650). Check whether the character was a u (for the breve) and adds 4 to the stack if so. Finally, add the ascii value of x (100) as well. The total adds up to the correct accent if needed or just an "x" if not.
```
>~:1+!#@_  
^ # #, : ++$\ _^#
```
Add all the values in the stack together, print it and keep a duplicate. Go back up for the next input.
[Answer]
# [R](https://www.r-project.org/), ~~75~~ 70 bytes
```
function(s)gsub('([cghjs])x','\\1\U302',gsub('(u)x','\\1\U306',s,T),T)
```
[Try it online!](https://tio.run/##TYrLCsIwEEX3fkVwkwSy8AFuRFz4CdqVdZGmTdqKiXYSHRG/PUZSQRjmzpxzh6g3UQerfOcsA24gVIyyozJtDyeOVNCynJfFcragYpThH6@oAHHgaaJmU4MdacBLIHc5XOSUTxLcYSCQBKD8mrP0rrdEBiRtsLXrt7lWoMJUqVTNWtwjb7R5vdfZ3R7N4J@hc9f8kxx54xjqlyNQmI74AQ "R – Try It Online")
-5 bytes thanks to [Giuseppe](https://codegolf.stackexchange.com/users/67312/giuseppe)
### Explanation
* `gsub('(u)x','\\1\U306',s,T)`: replace in `s` every occurrence of an uppercase or lowercase "u" (by using `ignore.case=TRUE` via the fourth argument `T`) followed by an "x" the "u" followed by the unicode for a breve
* `gsub('([cghjs])x','\\1\U302',gsub('(u)x','\\1\U306',s,T),T)`: take the result of that and replace every occurrence of an uppercase or lowercase (by using `ignore.case=TRUE` via the fourth argument `T`) "c", "g", "h", "j", or "s" followed by an "x" with the letter followed by the unicode for a circumflex
[Answer]
# [QuadR](https://github.com/abrudz/QuadRS), 25 bytes
Combining diacritics edition.
```
ux
([cghjs])x
 ̆&
 ̂\1
```
`i` flag
[Try it online!](https://tio.run/##HYk7DsIwEER7n2LlyilTU1BwBERFKBbb@IOIiT@wCNFQcDruZGykmafRm6WgirWKMhATe2msT4c24fuZxsb3NNZqyIFOGRPcMF6QbahAai4RdnnGHPwMWAhsmVXwa7YjSe09SiUsbWnQJ/N8rRhf7jrmR3HhyhmH1hbqlX/0KYl4dT8 "QuadR – Try It Online")
*Replace…*
```
(u)x         u followed by x and
([cghjs])x   any of these letters followed by x …
 ̆\1          by a breve followed by the first group (the u) and
 ̂\1          a circumflex followed by the first group (the letter)
```
*case **i**nsensitively*
Equivalent to the following Dyalog APL code:
```
'(u)x' '([cghjs])x'⎕R' ̆\1' ' ̂\1'
```
[Answer]
# C, ~~145~~ 144 bytes
Another C approach. Return by overwriting the input, using the fact that circumflex / breve are 2 bytes.
*-1 bytes thanks to [Steadybox](https://codegolf.stackexchange.com/users/61405/steadybox).*
```
i,t;f(char*s){for(t=1;*s;s++)if(*s^'x')for(i=12,t=1;i--;)t="cghjsuCGHJSU"[i]-*s?t:i*2;else t^1&&memcpy(s-1,"ĉĝĥĵŝŭĈĜĤĴŜŬ"+t,2),t=1;}
```
[Try it online!](https://tio.run/##VY49TsNAEIV7n2LlItl1bCl2ySpKkQJEG6WKEmlZ/LMB28Ezho0i93CHpIMOOrjB@lzGNinMVO/N9@ZppBdL2TTKRR5RmYjCAXaM8oLizOcOcJhMmIqoA9uxHrMOqJkfuB1VnscZzmwZJzsoF9c3t8uVvVYbz4E5Xikn4OEjhAS3/miUhqncHyh4vmubN3M2H@anPtdf5tWczLv5rk/1pz1BN2B9ddXIv2cIMHK0SDudJbgOptMNJ4BFV4duy3mPI4oXtS8RelNZlsqQpEJllFmXFmrHWpEQUAB5FkUq7MtZSxa6JNBS0KLDDwLzXUZEqUlSZvf5bj7IrrTUbe5O3tNELzULo/hY8UHg6SUs8FCqfD9YkoEeSD3U8p8ZIql7VzW/ "C (gcc) – Try It Online")
[Answer]
# Mathematica, 81 bytes or 57 bytes
`StringReplace[RemoveDiacritics@#<>"x"->#&/@Characters@"ĉĝĥĵŝŭĈĜĤĴŜŬ"]`
It applies a replacement rule where the letter without the hat together with an "x" is replaced by the letter.
Here is an alternative using the added accents character:
`StringReplace[{"ux"->"ŭ","Ux"->"Ŭ",c_~~"x":>c<>"̂"}]`
[Answer]
# [Perl 5](https://www.perl.org), 49 + 2 (`-p -C`) = ~~61~~ 51 bytes
```
s/[CGHJScghjs]\Kx/\x{0302}/g;s/[Uu]\Kx/\x{0306}/g
```
[Try it online!](https://tio.run/##TYmxDoIwFEX3fsUbdTAQjS4MDgwaHQmTONRSS1Fppa0@Q/h162MzOTe5OcfK/r6O0SWnfLc/FEI1rTtXR0wqHNJVuhwTlVEsw5/ckIxRoQbpPHfw4v2DA8sxgCPpkE/2xr1pO@ABoQldbdotsBIFUr6IetZggXN5VcOYAXu@Ze8/QRsLDAiGhJhGRyDC11ivTefiwv4A "Perl 5 – Try It Online")
*Saved 10 bytes thanks to [Nahuel Fouilleul](https://codegolf.stackexchange.com/users/70745/nahuel-fouilleul)*
[Answer]
# sed, 40 bytes (38 chars)
```
s/([cghjsCGHJS])x/\1̂/g
s/(u|U)x/\1̆/g
```
[Try it online!](https://tio.run/##VYy9bsIwEMd3P8XJEwwoYqUDA0JFXRET7WCc1AlVk4Dj9qqWhQGRdyhjN/oW9tZnqrk4rYDpfv@v00ncU7nxXkeduVTpUo9uJ3fThy5G9/2fbaQYBeZj1updpLznCjNIdCU0vIj1s@AwAG4P1x7jIzSgqalRNPaTqIplDsIgpCaPiYftcG/A0dgdrmru@1xjfIYS6c9Cxp0Up9hNHtX75ibs3dHWtG0i@@U@/yPGV6/JunozWVGG3oVkHIIFRAHoYgBsSLYoA//5tiYlsVW2Rv5blFVW5Nr3xic "sed – Try It Online")
I believe this is different enough from [iBug's answer](https://codegolf.stackexchange.com/a/149338/44694).
[Answer]
# [Lexurgy](https://www.lexurgy.com/sc), ~~60~~ 48 bytes
```
a:
x=>̂/{c,g,h,j,s,C,G,H,J,S} _
x=>̆/{U,u} _
```
Replaces `x` with the correct combining diacritic based on the preceding character.
* -12 bytes for removing the `Class`.
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 51 bytes
```
q"ĉĝĥĵŝŭĈĜĤĴŜŬ""cghjsuCGHJSU".{'x+@\/*}
```
[Try it online!](https://tio.run/##AT4Awf9jamFt//9xIsSJxJ3EpcS1xZ3FrcSIxJzEpMS0xZzFrCIiY2doanN1Q0dISlNVIi57J3grQFwvKn3//2N4eA "CJam – Try It Online")
Explanation:
```
q                   Read input
"ĉĝĥĵŝŭĈĜĤĴŜŬ"      String literal
"cghjsuCGHJSU"      Another string literal
.{                  Iterate over the strings in parallel
  'x+                 Add an 'x to the normal character
  @                   Rotate to bring the input to the top of stack
  \                   Swap to bring the "cx" to the top
  /                   Split the input on instances of "cx"
  *                   Join the input on instances of the accented character
}
```
[Answer]
## PowerShell, 58 bytes
It's 54 characters and saving it in PowerShell ISE makes it [UTF-8 + BOM](https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8) for 58 bytes. It doesn't render as nicely in a browser:
```
$args-replace'(?<=u)x','̆'-replace'(?<=[cghjs])x','̂'
```
regex replaces the x with the combining Unicode characters from @user202729's comment.
e.g.
```
PS C:\> .\eo.ps1 "Cxu vi sxatas la cxapelliterojn? Mi ankaux."
Ĉu vi ŝatas la ĉapelliterojn? Mi ankaŭ.
```
[Answer]
# Clojure, ~~126~~ 115 bytes
-11 bytes by changing the replacement map to a partition of a string.
```
#(reduce(fn[a[f r]](clojure.string/replace a(str f\x)(str r)))%(partition 2"cĉgĝhĥjĵsŝuŭCĈGĜHĤJĴSŜUŬ")) 
```
A reduction over a map of replacements to look for, and what to replace them with.
Still working on a way to compress the replacement map.
```
(defn translate [^String esperanto]
  (reduce (fn [acc [f r]] (clojure.string/replace
                            acc ; Replace the translation so far by
                            (str f \x) ; adding a x after each character, search for it in the string,
                            (str r))) ; and replace it with a stringified accented char
          esperanto ; Before the reduction happens, the accumulator is the original string
          ; A list of [char-to-find what-to-replace-with] pairs
          (partition 2"cĉgĝhĥjĵsŝuŭCĈGĜHĤJĴSŜUŬ")))))
```
[Answer]
# JavaScript (ES6), 91 bytes
```
(i,s='cĉgĝhĥjĵsŝuŭCĈGĜHĤJĴSŜUŬ')=>i.replace(/.x/g,m=>s[1+s.search(m[0])||s]||m)
```
[Try it online!](https://tio.run/##bZK7bsIwFIb3PMVRlyRqGtq1yHRAVauuiAkxuMa5UHJpnFBXhJ28A9nKBlv7BvZzpUkoIiHdjv19/@/BZ46XmJHIDeMbP5jRwkKF5hoMqURktsgdsZuLHybzRB6GYvMkts/i60V8j@R2LPeqjgauGdFwgQnVeibv2YaHBmxyd81MRnFEHM2b3E71NGXTNPX0ggQ@i4FgRhkgmCgAK3D9MInv4crmLlAWYwZLHHn4yoAgiY9I5G0Ea6MVHfIEWBlnHFfSG46DuQ844eAk/qycH1ptmwRk2Sjzli0PZ/vygTEnvCx/JTPN4SOuU8terfvNUrkXWVlYGWIntyfjsuj9g0bxZ@IGYTPcuL0MQNODDm7SDuRNyruYtDj5R2g3iKyjEN5SRFY9o0z7SvXTwYKai8DW1NqG9M8rBw/HxKFM1ZV6F0wriB5xuS0EDVbNJDHrqKGmqmGdTnp9JOaxDSF0JvpaL34B)
[Answer]
# [Scala](http://www.scala-lang.org/), 110 bytes
Boring regex solution:
```
def?(s:String)="(.)x".r.replaceAllIn(s,m=>m.group(0)(0)+(if(m.group(0)(0).toUpper=='U')"\u0306"else"\u0302"))
```
Old scala solution (116 bytes)
```
def?(s:String)=s.foldLeft("")((r,c)=>if(c=='x')r.init+r.last+(if(r.last.toUpper=='U')"\u0306"else"\u0302")else r+c)
```
Ungolfed
```
def?(s:String)=
  s.foldLeft("")((r,c)=>  // 'Fold' string with empty string as first result
    if(c=='x')            // If current character is x
      r.init+             // Take the every character from result but the last
        r.last+           // The last character from result and add
          (if(r.last.toUpper=='U')
            "\u0306"      // combining breve if 'u' or 'U'
          else"\u0302")   // combining circumflex in any other case
 else r+c                 // Otherwise return result + character
)
```
[Answer]
# JavaScript, 35 chars, 36 bytes
```
s=>s.replace(/([cghjsu])x/gi,"$1̂")
```
[Answer]
# [Raku](https://github.com/nxadm/rakudo-pkg), ~~57~~ 50 bytes
```
{S:g:i/(<[cghjsu]>)x/{$0~chr 770+4*("u"eq$0.lc)}/}
```
[Try it online!](https://tio.run/##PcrNCoJAFEDhfU9xGSS1IF1Egvaz6BGkVbS4jeOMplaOE1fEXn0yiHYHvvMQbbWxdT/Pd3ZIYxkXgbc9c6lKbS57n4LBCd9ctRBF4XK98Jhh4umEq4r7YzBajT3kwCQVIHSHGl7Y1siS2Q@OZEBPqAm/esPuXjaAhkCZJpv68H/dE3GavivPPEUp@SKXw5i49gM "Perl 6 – Try It Online")
[Answer]
# [Zsh](https://www.zsh.org/), 71 bytes
```
for 2 3 (`fold -1<<<${a=cĉgĝhĥjĵsŝuŭ}${a:u}`)1=${1//$2x/$3}
<<<$1
```
[Try it online!](https://tio.run/##qyrO@F@cWqKgm6@QW5pTkplUWZL6Py2/SMFIwVhBIyEtPydFQdfQxsZGpTrRNvlIZ/qRuRlHlmYd2Vp8dG7p0bW1QGGr0toETUNblWpDfX0Vowp9FeNaLpAGw////ztXlCoUV2QCcWJJYrFCdmJJflaeQmJphUJGaV4KkG0PAA "Zsh – Try It Online")
[Answer]
# sed, 108 bytes
```
s/cx/ĉ/g
s/gx/ĝ/g
s/hx/ĥ/g
s/jx/ĵ/g
s/sx/ŝ/g
s/ux/ŭ/g
s/Cx/Ĉ/g
s/Gx/Ĝ/g
s/Hx/Ĥ/g
s/Jx/Ĵ/g
s/Sx/Ŝ/g
s/Ux/Ŭ/g
```
]