阿卡林语&普通话,简化拼音 - 标准拼音html转换器

先上代码

<!DOCTYPE html>
<html lang="en">

<head>
    <title>阿卡林语简化拼音转标准拼音</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="bigBox">
        <h1>阿卡林语简化拼音转标准拼音</h1>
        <p id="shijian">2020年01月01日 12:00:00</p>
        <p id="pinyinShili">简化拼音示例:pin1 yin1 &nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;标准拼音示例:pīn yīn</p>
        <textarea id='input_div' placeholder="&nbsp;输入需要转换的简化拼音,多个拼音请使用空格进行分隔"></textarea>
        <p></p>
        <!-- <hr> -->
        <button id="btn1">阿卡林语简化拼音转换成标准拼音</button>
        <button id="btn2">普通话简化拼音转换成标准拼音</button>
        <button id="btn3">清空</button>
        <p></p>
        <!-- <hr> -->
        <textarea id='outDiv' placeholder="&nbsp;转化结果在这里"></textarea>
        友商链接:
        <a href="http://xh.5156edu.com/conversion.html" target="_blank">汉字转普通话拼音、</a>
        <a href="https://hongkongvision.com/tool/cc_py_conv_zh" target="_blank">汉字转广州话拼音</a>
    </div>
    <style>
        #shijian {
            position: absolute;
            left: 392px;
            top: 35px;
            font-size: 16px;
            font-weight: 400;
        }

        h1 {
            margin-top: -10px;
            font-size: 26px;
        }

        #pinyinShili {
            margin-top: -10px;
            font-size: 12px;
        }

        a {
            color: #000000;
            cursor: pointer;
            text-decoration: none;
            font-weight: 400;
        }

        a:hover {
            /* color: blueviolet; */
            color: #000;
            font-weight: 600;
        }

        #bigBox {
            margin: 10px auto;
            width: 680px;
            height: 710px;
            border: 1px solid #ddd;
            box-shadow: 5px 5px 3px #888888;
            position: relative;
        }

        div {
            box-sizing: border-box;
            margin: 10px;
            padding: 20px;
        }

        #btn1,
        #btn2 {
            width: 260px;
            height: 40px;
            font-size: 15px;
            margin-left: 10px;
            font-weight: 400;
            cursor: pointer;
        }

        #btn3 {
            width: 70px;
            height: 40px;
            font-size: 15px;
            margin-left: 10px;
            font-weight: 400;
            cursor: pointer;
        }

        #btn1:hover,
        #btn2:hover,
        #btn3:hover {
            font-weight: 600;
        }

        #input_div,
        #outDiv {
            resize: none;
            width: 640px;
            height: 260px;
            text-rendering: auto;
            color: -internal-light-dark(black, white);
            letter-spacing: normal;
            word-spacing: normal;
            text-transform: none;
            text-indent: 0px;
            text-shadow: none;
            display: inline-block;
            text-align: start;
            appearance: textarea;
            background-color: -internal-light-dark(rgb(255, 255, 255), rgb(59, 59, 59));
            -webkit-rtl-ordering: logical;
            flex-direction: column;
            cursor: text;
            white-space: pre-wrap;
            overflow-wrap: break-word;
            box-sizing: border-box;
            margin: 0em;
            font: 400 13.3333px Arial;
            font-size: 18px;
            border-width: 1px;
            border-style: solid;
            border-color: -internal-light-dark(rgb(118, 118, 118), rgb(133, 133, 133));
            border-image: initial;
            padding: 2px 0px 0px 2px;
        }
    </style>
</body>
<!-- 阿卡林语简化拼音转换成标准拼音 -->
<script>
    function getRealAkalinPinyin(str = 'qing3 shu1 ru4 pin1 yin1') {
        str = str.toLowerCase()
        str = str.replace(/[\r\n]/g, ' ')
        str = str.replace(/v/g, 'ü')
        var strArr = str.split(' ')
        var result = []
        for (let index = 0; index < strArr.length; index++) {
            result.push(transToStdAkalinPinyin(strArr[index]))
        }
        for (let tag = 0; tag < strArr.length; tag++) {
            result[tag] = processingAkalinPinyinError(result[tag].toString())
        }
        var printResult = result.join('').toString()
        for (let jj = 0; jj < printResult.length; jj++) {
            printResult = printResult.replace("  ", " ");
            printResult = printResult.replace("   ", " ");
            printResult = printResult.replace("    ", " ");
            printResult = printResult.replace("     ", " ");
            printResult = printResult.replace("      ", " ");
            printResult = printResult.replace("       ", " ");
            printResult = printResult.replace("        ", " ");
            printResult = printResult.replace("         ", " ");
            printResult = printResult.replace("          ", " ");
        }
        console.log(printResult);
        return printResult;
    }
    function transToStdAkalinPinyin(pinyin) {
        let temp = pinyin.split('')
        if (temp[temp.length - 1] != '1' && temp[temp.length - 1] != '2' &&
            temp[temp.length - 1] != '3' && temp[temp.length - 1] != '4') {
            temp.push(' ')
            return temp.join('')
        } else {
            if (temp[temp.length - 1] == "1") {
                for (let index = 0; index < temp.length; index++) {
                    if (temp[index] == 'a') { temp[index] = 'ā' }
                    if (temp[index] == 'o') { temp[index] = 'ō' }
                    if (temp[index] == 'e') { temp[index] = 'ē' }
                    if (temp[index] == 'i') { temp[index] = 'ī' }
                    if (temp[index] == 'u') { temp[index] = 'ū' }
                    if (temp[index] == 'ü') { temp[index] = 'ǖ' }
                }
            }
            if (temp[temp.length - 1] == "2") {
                for (let index = 0; index < temp.length; index++) {
                    if (temp[index] == 'a') { temp[index] = 'á' }
                    if (temp[index] == 'o') { temp[index] = 'ó' }
                    if (temp[index] == 'e') { temp[index] = 'é' }
                    if (temp[index] == 'i') { temp[index] = 'í' }
                    if (temp[index] == 'u') { temp[index] = 'ú' }
                    if (temp[index] == 'ü') { temp[index] = 'ǘ' }
                }
            }
            if (temp[temp.length - 1] == "3") {
                for (let index = 0; index < temp.length; index++) {
                    if (temp[index] == 'a') { temp[index] = 'ǎ' }
                    if (temp[index] == 'o') { temp[index] = 'ǒ' }
                    if (temp[index] == 'e') { temp[index] = 'ě' }
                    if (temp[index] == 'i') { temp[index] = 'ǐ' }
                    if (temp[index] == 'u') { temp[index] = 'ǔ' }
                    if (temp[index] == 'ü') { temp[index] = 'ǚ' }
                }
            }
            if (temp[temp.length - 1] == "4") {
                for (let index = 0; index < temp.length; index++) {
                    if (temp[index] == 'a') { temp[index] = 'à' }
                    if (temp[index] == 'o') { temp[index] = 'ò' }
                    if (temp[index] == 'e') { temp[index] = 'è' }
                    if (temp[index] == 'i') { temp[index] = 'ì' }
                    if (temp[index] == 'u') { temp[index] = 'ù' }
                    if (temp[index] == 'ü') { temp[index] = 'ǜ' }
                }
            }
            temp[temp.length - 1] = ''
            temp.push(' ')
            return temp.join('')
        }
    }
    function processingAkalinPinyinError(str) {
        var n = str
        n = n.replace("āī", "āi").replace("áí", "ái").replace("ǎǐ", "ǎi").replace("àì", "ài");
        n = n.replace("īō", "iō").replace("íó", "ió").replace("ǐǒ", "iǒ").replace("ìò", "iò");
        n = n.replace("ūō", "uō").replace("úó", "uó").replace("ǔǒ", "uǒ").replace("ùò", "uò");
        n = n.replace("ūū", "ūu").replace("úú", "úu").replace("ǔǔ", "ǔu").replace("ùù", "ùu");
        n = n.replace("ǖē", "üē").replace("ǘé", "üé").replace("ǚě", "üě").replace("ǜè", "üè");
        n = n.replace("ūā", "uā").replace("úá", "uá").replace("ǔǎ", "uǎ").replace("ùà", "uà");
        n = n.replace("ūē", "uē").replace("úé", "ué").replace("ǔě", "uě").replace("ùè", "uè");
        n = n.replace("īē", "iē").replace("íé", "ié").replace("ǐě", "iě").replace("ìè", "iè");
        n = n.replace("āō", "āo").replace("áó", "áo").replace("ǎǒ", "ǎo").replace("àò", "ào");
        n = n.replace("ēī", "ēi").replace("éí", "éi").replace("ěǐ", "ěi").replace("èì", "èi");
        n = n.replace("īā", "iā").replace("íá", "iá").replace("ǐǎ", "iǎ").replace("ìà", "ià");
        n = n.replace("īū", "iū").replace("íú", "iú").replace("ǐǔ", "iǔ").replace("ìù", "iù");
        n = n.replace("ōū", "ōu").replace("óú", "óu").replace("ǒǔ", "ǒu").replace("òù", "òu");
        n = n.replace("ūī", "uī").replace("úí", "uí").replace("ǔǐ", "uǐ").replace("ùì", "uì");
        n = n.replace("ǖāi", "üāi").replace("ǘái", "üái").replace("ǚǎi", "üǎi").replace("ǜài", "üài");
        n = n.replace("ǖōn", "üōn").replace("ǘón", "üón").replace("ǚǒn", "üǒn").replace("ǜòn", "üòn");
        n = n.replace("ǖān", "üān").replace("ǘán", "üán").replace("ǚǎn", "üǎn").replace("ǜàn", "üàn");
        n = n.replace("īāo", "iāo").replace("íáo", "iáo").replace("ǐǎo", "iǎo").replace("ìào", "iào");
        n = n.replace("īān", "iān").replace("íán", "ián").replace("ǐǎn", "iǎn").replace("ìàn", "iàn");
        n = n.replace("ūān", "uān").replace("úán", "uán").replace("ǔǎn", "uǎn").replace("ùàn", "uàn");
        n = n.replace("ūēr", "uēr").replace("úér", "uér").replace("ǔěr", "uěr").replace("ùèr", "uèr");
        n = n.replace("īēng", "iēng").replace("íéng", "iéng").replace("ǐěng", "iěng").replace("ìèng", "ièng");
        n = n.replace("īōng", "iōng").replace("íóng", "ióng").replace("ǐǒng", "iǒng").replace("ìòng", "iòng");
        return n
    }
    //---------------
    document.getElementById('btn1').onclick = function () {
        var text = document.getElementById('input_div').value
        // console.log(text)
        var text2 = getRealAkalinPinyin(text)
        // console.log(text2)
        document.getElementById('outDiv').value = text2
    }
</script>
<!-- 普通话简化拼音转换成标准拼音 -->
<script>
    function getStdPutonghuaPinyin(str = 'qing3 shu1 ru4 pin1 yin1') {
        str = str.toLowerCase()
        str = str.replace(/[\r\n]/g, ' ')
        str = str.replace(/v/g, 'ü')
        var strArr = str.split(' ')
        var result = []
        for (let index = 0; index < strArr.length; index++) {
            result.push(transToStd(strArr[index]))
        }
        for (let tag = 0; tag < strArr.length; tag++) {
            result[tag] = errorRecovery(result[tag].toString())
        }
        var printResult = result.join('').toString()
        for (let jj = 0; jj < printResult.length; jj++) {
            printResult = printResult.replace("  ", " ");
            printResult = printResult.replace("   ", " ");
            printResult = printResult.replace("    ", " ");
            printResult = printResult.replace("     ", " ");
            printResult = printResult.replace("      ", " ");
            printResult = printResult.replace("       ", " ");
            printResult = printResult.replace("        ", " ");
            printResult = printResult.replace("         ", " ");
            printResult = printResult.replace("          ", " ");
        }
        console.log(printResult);
        return printResult;
    }

    function transToStd(pinyin) {
        let temp = pinyin.split('')
        if (temp[temp.length - 1] != '1' && temp[temp.length - 1] != '2' &&
            temp[temp.length - 1] != '3' && temp[temp.length - 1] != '4') {
            temp.push(' ')
            return temp.join('')
        } else {
            if (temp[temp.length - 1] == "1") {
                for (let index = 0; index < temp.length; index++) {
                    if (temp[index] == 'a') { temp[index] = 'ā' }
                    if (temp[index] == 'o') { temp[index] = 'ō' }
                    if (temp[index] == 'e') { temp[index] = 'ē' }
                    if (temp[index] == 'i') { temp[index] = 'ī' }
                    if (temp[index] == 'u') { temp[index] = 'ū' }
                    if (temp[index] == 'ü') { temp[index] = 'ǖ' }
                }
            }
            if (temp[temp.length - 1] == "2") {
                for (let index = 0; index < temp.length; index++) {
                    if (temp[index] == 'a') { temp[index] = 'á' }
                    if (temp[index] == 'o') { temp[index] = 'ó' }
                    if (temp[index] == 'e') { temp[index] = 'é' }
                    if (temp[index] == 'i') { temp[index] = 'í' }
                    if (temp[index] == 'u') { temp[index] = 'ú' }
                    if (temp[index] == 'ü') { temp[index] = 'ǘ' }
                }
            }
            if (temp[temp.length - 1] == "3") {
                for (let index = 0; index < temp.length; index++) {
                    if (temp[index] == 'a') { temp[index] = 'ǎ' }
                    if (temp[index] == 'o') { temp[index] = 'ǒ' }
                    if (temp[index] == 'e') { temp[index] = 'ě' }
                    if (temp[index] == 'i') { temp[index] = 'ǐ' }
                    if (temp[index] == 'u') { temp[index] = 'ǔ' }
                    if (temp[index] == 'ü') { temp[index] = 'ǚ' }
                }
            }
            if (temp[temp.length - 1] == "4") {
                for (let index = 0; index < temp.length; index++) {
                    if (temp[index] == 'a') { temp[index] = 'à' }
                    if (temp[index] == 'o') { temp[index] = 'ò' }
                    if (temp[index] == 'e') { temp[index] = 'è' }
                    if (temp[index] == 'i') { temp[index] = 'ì' }
                    if (temp[index] == 'u') { temp[index] = 'ù' }
                    if (temp[index] == 'ü') { temp[index] = 'ǜ' }
                }
            }
            temp[temp.length - 1] = ''
            temp.push(' ')
            return temp.join('')
        }
    }
    function errorRecovery(str) {
        var n = str
        n = n.replace("āī", "āi").replace("áí", "ái").replace("ǎǐ", "ǎi").replace("àì", "ài");
        n = n.replace("ēī", "ēi").replace("éí", "éi").replace("ěǐ", "ěi").replace("èì", "èi");
        n = n.replace("ūī", "uī").replace("úí", "uí").replace("ǔǐ", "uǐ").replace("ùì", "uì");
        n = n.replace("āō", "āo").replace("áó", "áo").replace("ǎǒ", "ǎo").replace("àò", "ào");
        n = n.replace("ōū", "ōu").replace("óú", "óu").replace("ǒǔ", "ǒu").replace("òù", "òu");
        n = n.replace("īū", "iū").replace("íú", "iú").replace("ǐǔ", "iǔ").replace("ìù", "iù");
        n = n.replace("īē", "iē").replace("íé", "ié").replace("ǐě", "iě").replace("ìè", "iè");
        n = n.replace("ǖē", "üē").replace("ǘé", "üé").replace("ǚě", "üě").replace("ǜè", "üè");
        n = n.replace("ūā", "uā").replace("úá", "uá").replace("ǔǎ", "uǎ").replace("ùà", "uà");
        n = n.replace("īā", "iā").replace("íá", "iá").replace("ǐǎ", "iǎ").replace("ìà", "ià");
        n = n.replace("īān", "iān").replace("íán", "ián").replace("ǐǎn", "iǎn").replace("ìàn", "iàn");
        n = n.replace("ūān", "uān").replace("úán", "uán").replace("ǔǎn", "uǎn").replace("ùàn", "uàn");
        n = n.replace("īōn", "iōn").replace("íón", "ión").replace("ǐǒn", "iǒn").replace("ìòn", "iòn");
        n = n.replace("īāo", "iāo").replace("íáo", "iáo").replace("ǐǎo", "iǎo").replace("ìào", "iào");
        n = n.replace("īōng", "iōng").replace("íóng", "ióng").replace("ǐǒng", "iǒng").replace("ìòng", "iòng");
        return n
    }
    // getStdPutonghuaPinyin('')
    document.getElementById('btn2').onclick = function () {
        var text3 = document.getElementById('input_div').value
        // console.log(text3)
        var text4 = getRealAkalinPinyin(text3)
        // console.log(text4)
        text4 = text4.replace(/jǖ/g, "jū").replace(/jǘ/g, "jú").replace(/jǚ/g, "jǔ").replace(/jǜ/g, "jù");
        text4 = text4.replace(/qǖ/g, "qū").replace(/qǘ/g, "qú").replace(/qǚ/g, "qǔ").replace(/qǜ/g, "qù");
        text4 = text4.replace(/xǖ/g, "xū").replace(/xǘ/g, "xú").replace(/xǚ/g, "xǔ").replace(/xǜ/g, "xù");
        text4 = text4.replace(/yǖ/g, "yū").replace(/yǘ/g, "yú").replace(/yǚ/g, "yǔ").replace(/yǜ/g, "yù");
        document.getElementById('outDiv').value = text4
    }
</script>
<!-- 清空输入输出框 -->
<script>
    document.getElementById('btn3').onclick = function () {
        document.getElementById('input_div').value = '';
        document.getElementById('outDiv').value = '';
    }
</script>
<!-- 显示时间 -->
<script>
    function reTime() {
        var shijianP = document.getElementById('shijian');
        var time = new Date();
        var nian = time.getFullYear();
        var yue = time.getMonth() + 1;
        if (yue < 10) {
            yue = '0' + yue;
        }
        var ri = time.getDate();
        if (ri < 10) {
            ri = '0' + ri;
        }
        var shi = time.getHours();
        if (shi < 10) {
            shi = '0' + shi;
        }
        var fen = time.getMinutes();
        if (fen < 10) {
            fen = '0' + fen;
        }
        var miao = time.getSeconds();
        if (miao < 10) {
            miao = '0' + miao;
        }
        var milliSeconds = time.getMilliseconds()
        var haomiao = 0;
        if (milliSeconds < 100) {
            haomiao = '0' + milliSeconds;
        } else {
            haomiao = milliSeconds + '0';
        }
        haomiao = haomiao.substr(0, 2);
        var libaiji = time.getDay();
        if (libaiji == 0) {
            libaiji = "天"
        } else if (libaiji == 1) {
            libaiji = "一"
        } else if (libaiji == 2) {
            libaiji = "二"
        } else if (libaiji == 3) {
            libaiji = "三"
        } else if (libaiji == 4) {
            libaiji = "四"
        } else if (libaiji == 5) {
            libaiji = "五"
        } else if (libaiji == 6) {
            libaiji = "六"
        }
        var timeText = nian + '年' + yue + '月' + ri + '日' + ' ' + '星期' + libaiji + ' ' + shi + ':' + fen + ':' + miao + ':' + haomiao;
        shijianP.innerText = timeText;
    }

    function reTimeInterval() {
        setTimeout(() => {
            reTime();
            reTimeInterval();
        }, 1000 / 30);
    }
    reTimeInterval();
</script>

</html>

运行效果


程序界面

试用
原话:阿卡林语简化拼音转标准拼音
输入:a1 ka3 lin2 yv3 jian3 hua4 pin1 yin1 zhuan3 huan4 qi4
输出:ā kǎ lín yǔ jiǎn huà pīn yīn zhuǎn huàn qì

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 205,033评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,725评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,473评论 0 338
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,846评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,848评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,691评论 1 282
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,053评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,700评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 42,856评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,676评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,787评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,430评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,034评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,990评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,218评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,174评论 2 352
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,526评论 2 343

推荐阅读更多精彩内容

  • 前言:我们平时在用js开发中总会遇到一些排序问题,比如微信里面按照abcd...z给联系人的排序,或者模仿电话簿里...
    fangcaiwen阅读 1,662评论 0 1
  • 普通话水平测试易错词语 A. 挨近āi 挨打ái 癌ái 矮ǎi 隘口ài 碍眼ài 按捺 ànnà 肮脏āng...
    思思830阅读 2,381评论 1 0
  • 久违的晴天,家长会。 家长大会开好到教室时,离放学已经没多少时间了。班主任说已经安排了三个家长分享经验。 放学铃声...
    飘雪儿5阅读 7,485评论 16 22
  • 今天感恩节哎,感谢一直在我身边的亲朋好友。感恩相遇!感恩不离不弃。 中午开了第一次的党会,身份的转变要...
    迷月闪星情阅读 10,551评论 0 11
  • 可爱进取,孤独成精。努力飞翔,天堂翱翔。战争美好,孤独进取。胆大飞翔,成就辉煌。努力进取,遥望,和谐家园。可爱游走...
    赵原野阅读 2,715评论 1 1