将数组拼音转换成真正的带标点的拼音
@param pinyinWithoutTone 类似 xu2e这样的带数字的拼音
429868
function(pinyinWithoutTone)
        {
            var newToneMap = {};
            for(var i in toneMap) newToneMap[toneMap[i]] = i;
            return (pinyinWithoutTone || '').replace(/[a-z]\d/g, function(m) {
                return newToneMap[m] || m;
            });
        }
911857
function callBack($from,$to,$customerSerNum,$fromSerNum,$promptTone)
	  {
        //子帐号鉴权信息验证，对必选参数进行判空。
        $auth=$this->subAuth();
        if($auth!=""){
            return $auth;
        }
        // 拼接请求包体
        if($this->BodyType=="json"){
           $body= "{'from':'$from','to':'$to','customerSerNum':'$customerSerNum','fromSerNum':'$fromSerNum','promptTone':'$promptTone'}";
        }else{
           $body= "<CallBack>
                     <from>$from</from>
                     <to>$to</to>
                     <customerSerNum>$customerSerNum</customerSerNum>
                     <fromSerNum>$fromSerNum</fromSerNum>
                     <promptTone>$promptTone</promptTone>
                   </CallBack>";
        }
        $this->showlog("request body = ".$body);
        // 大写的sig参数
        $sig =  strtoupper(md5($this->SubAccountSid . $this->SubAccountToken . $this->Batch));
        // 生成请求URL
        $url="https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/SubAccounts/$this->SubAccountSid/Calls/Callback?sig=$sig";
        $this->showlog("request url = ".$url);
        // 生成授权：子帐号Id + 英文冒号 + 时间戳
        $authen=base64_encode($this->SubAccountSid . ":" . $this->Batch);
        // 生成包头
        $header = array("Accept:application/$this->BodyType","Content-Type:application/$this->BodyType;charset=utf-8","Authorization:$authen");
        // 发请求
        $result = $this->curl_post($url,$body,$header);
        $this->showlog("response body = ".$result);
        if($this->BodyType=="json"){//JSON格式
           $datas=json_decode($result);
        }else{ //xml格式
           $datas = simplexml_load_string(trim($result," \t\n\r"));
        }
      //  if($datas == FALSE){
//            $datas = new stdClass();
//            $datas->statusCode = '172003';
//            $datas->statusMsg = '返回包体错误'; 
//        }
        return $datas;
	}
35837
function (jsonObj) {
    if ($bc_$4.pN) {
      var obj = jsonObj || {
        callback: 'console.log',
        key: '',
        value: ''
      };

      // 统一向后兼容处理
      for (var key in jsonObj) {
        if (jsonObj.hasOwnProperty(key)) {
          obj[key] = jsonObj[key];
        }
      }

      $bc_$4.pN.window.setInfoToUserDefaults(JSON.stringify(obj));
    }
  }
1226769
def pinyin(char, variant='mandarin', sep=' ', out='tones'):
    
    if len(char) > 1:
        return sep.join([pinyin(c, variant=variant, sep=sep, out=out) for c in char])

    if not is_chinese(char):
        return char

    if char in _cd.GBK: 
        char = gbk2big5(char)

    out_char = _cd.UNIHAN.get(char, {variant: '?({0}'.format(char)}).get(variant, '!({0})'.format(char))

    if out != 'tones':
        out_char = ''.join([tone_converter.get(x, x) for x in out_char])    

    return out_char
1221356
protected function convertToValidFilenameWithoutExtension(string $filenameWithoutExtension): string
    {
        /** @var string 制御文字、先頭末尾の空白を取り除いた文字列。 */
        $trimed = preg_replace('/^\\p{Z}+|\\p{C}+|\\p{Z}+$/u', '', $filenameWithoutExtension);
        
        return $trimed === ''
            ? (new FilenameValidator())->generateRandomFilename()
            : preg_replace_callback(
                '/^(CON|PRN|AUX|CLOCK\\$|NUL|(COM|LPT)[1-9])$|["*.\\/:<>?\\\\|]+/i',
                function (array $matches): string {
                    $breakIterator = \IntlCodePointBreakIterator::createCodePointInstance();
                    $breakIterator->setText($matches[0]);
                    $fullWidthChars = '';
                    foreach ($breakIterator as $index) {
                        if ($index > 0) {
                            $fullWidthChars .= \IntlChar::chr(
                                $breakIterator->getLastCodePoint() + static::BETWEEN_HALF_AND_FULL
                            );
                        }
                    }
                    return $fullWidthChars;
                },
                $trimed
            );
    }
936038
public void analyze(AnalyzeContext context) {
		boolean bufferLockFlag = false;
		//处理英文字母
		bufferLockFlag = this.processEnglishLetter(context) || bufferLockFlag;
		//处理阿拉伯字母
		bufferLockFlag = this.processArabicLetter(context) || bufferLockFlag;
		//处理混合字母
		bufferLockFlag = this.processMixLetter(context) || bufferLockFlag;
		
		//判断是否锁定缓冲区
		if(bufferLockFlag){
			context.lockBuffer(SEGMENTER_NAME);
		}else{
			//对缓冲区解锁
			context.unlockBuffer(SEGMENTER_NAME);
		}
	}
574121
function () {
        const editor = this.editor
        const $textElem = editor.$textElem

        $textElem.on('keydown', e => {
            if (e.keyCode !== 8) {
                return
            }
            const txtHtml = $textElem.html().toLowerCase().trim()
            if (txtHtml === '<p><br></p>') {
                // 最后剩下一个空行，就不再删除了
                e.preventDefault()
                return
            }
        })

        $textElem.on('keyup', e => {
            if (e.keyCode !== 8) {
                return
            }
            let $p
            const txtHtml = $textElem.html().toLowerCase().trim()

            // firefox 时用 txtHtml === '<br>' 判断，其他用 !txtHtml 判断
            if (!txtHtml || txtHtml === '<br>') {
                // 内容空了
                $p = $('<p><br/></p>')
                $textElem.html('') // 一定要先清空，否则在 firefox 下有问题
                $textElem.append($p)
                editor.selection.createRangeByElem($p, false, true)
                editor.selection.restoreSelection()
            }
        })

    }
980174
function (withWhitespace) {
                var tok;

                // 如果已经有缓存的预读
                if (this.peeked) {
                    if (!withWhitespace && this.peeked.type == lexer.TOKEN_WHITESPACE) {
                        this.peeked = null;
                    } else {
                        tok = this.peeked;
                        this.peeked = null;
                        return tok;
                    }
                }

                tok = this.tokens.nextToken();

                // ... 默认如果下一个tokens是空白字符 则返回下下个token
                // ... 当withWhitespace为true时 即nextToken(true) 则不考虑是否是空白字符
                if (!withWhitespace) {
                    while (tok && tok.type == lexer.TOKEN_WHITESPACE) {
                        tok = this.tokens.nextToken();
                    }
                }

                return tok;
            }
191576
function gotoLoadLanguageFile (langsFiles, ext, successCallback) {
    /**
     * [_tryLoad 尝试加载]
     * @param  {[string]} file        [文件路径]
     * @param  {[string]} langKey     [关键KEY]
     * @param  {[string]} ext         [扩展名：只支持两种: .josn 和 .js]
     * @param  {[function]} fnNext     [出错下一步执行函数]
     * @param  {[function]} fnCallback [成功加载回调函数]
     * @return {[type]}             [description]
     */
    function _tryLoad (file, langKey, ext, fnNext, fnCallback) {
      try {
        $.ajax({
          url: file,
          dataType: (ext === '.js' ? 'script' : 'json'),
          success: function (data, status) {
            console.log('[x] ' + status + ' =' + file);
            var obj = {
              data: data,
              status: status,
              info: {
                file: file,
                langKey: langKey,
                langID: googleLangIDMaps.getGoogleLangID(langKey),
                ext: ext
              }
            };

            t$.loadedLanguage.insert(obj.info, ext);
            fnCallback && fnCallback(obj);
          },
          error: function (req, status, err) {
            console.log(err);
            try {
              throw new Error('[x]no found... continue.. = ' + file)
            } catch (error) {
              console.warn(error);
              fnNext && fnNext(fnCallback);
            }
          }
        });
      } catch (error) {
        console.error(error);
        fnNext && fnNext();
      }
    }

    /**
     * [gotoTry 尝试]
     * @param  {[type]}   list     [文件对象列表]
     * @param  {[type]}   ext      [扩展名]
     * @param  {Function} callback [成功回调]
     * @return {[type]}            [description]
     */
    function _gotoTry (list, ext, callback) {
      if (Tool.isArray(list) && list.length > 0) {
        var ele = list[0];
        _tryLoad(ele.path, ele.key, ext, function (cb) {
          var newLangFileList = list.splice(1);
          _gotoTry(newLangFileList, ext, cb);
        }, callback);
      } else {
        console.warn('[x] language list length is 0 or not a array. TYPE=' + Tool.getType(list));
      }
    }

    // Try start
    _gotoTry(langsFiles, ext, successCallback);
  }
977137
public function transformWithoutTone($inputChar, $delimiter=' ', $outsideIgnore=true)
    {
        $charWithTone = $this->transformWithTone($inputChar, $delimiter, $outsideIgnore);

        $charWithoutTone = str_replace(
            array('ā', 'á', 'ǎ', 'à', 'ō', 'ó', 'ǒ', 'ò', 'ē', 'é', 'ě', 'è', 'ī', 'í', 'ǐ', 'ì', 'ū', 'ú', 'ǔ', 'ù', 'ǖ', 'ǘ', 'ǚ', 'ǜ', 'ü'), 
            array('a', 'a', 'a', 'a', 'o', 'o', 'o', 'o', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'u', 'u', 'u', 'u', 'v', 'v', 'v', 'v', 'v'),
            $charWithTone
        );

        return $charWithoutTone;

    }
695032
public synchronized static String mask(String inString) {
        String outString = null;

        if (inString != null) {
            char[] outStringBuffer = new char[inString.length()];

            for (int i = 0; i < inString.length(); i++) {
                outStringBuffer[i] = '*';
            }

            outString = new String(outStringBuffer);
        }

        return outString;
    }
251212
def convert_iou(pinyin):
    
    return IU_RE.sub(lambda m: m.group(1) + IU_MAP[m.group(2)], pinyin)
1116719
public static String getPinyin(String text, PinyinFormat format) {
		char[] array = text.toCharArray();
		StringBuffer sb = new StringBuffer();
		String sep = ""; // 分隔符
		if ($.notNull(format)) {
			String separator = format.getSeparator();
			sep = $.notNull(separator) ? separator : sep;
		}
		for (int i = 0; i < array.length; i++) {
			char c = array[i];
			if (!String.valueOf(c).matches(chineseCharacteRegex)) {
				if (!sb.toString().endsWith(sep) && sb.length() > 0) {
					sb.append(sep);
				}
				sb.append(getPinyin(c, format));
				if (i != array.length - 1) {
					sb.append(sep);
				}
			} else {
				sb.append(c);
			}
		}
		return sb.toString();
	}
915883
function TTFReader(options) {
            options = options || {};
            options.subset = options.subset || [];       // 子集
            options.hinting = options.hinting || false; // 不保留hints信息
            options.compound2simple = options.compound2simple || false; // 复合字形转简单字形

            this.options = options;
        }
180435
static function DetectAndSwitch($filename,$out_charset) {
		$fpr = fopen($filename,"r");
		$char1 = fread($fpr,1);
		$char2 = fread($fpr,1);
		$char3 = fread($fpr,1);

		$originEncoding = "";

		if($char1==chr(239) && $char2==chr(187) && $char3==chr(191))//UTF-8 WITH BOM
			$originEncoding = "UTF-8 WITH BOM";
		elseif($char1==chr(255) && $char2==chr(254))//UNICODE LE
		{
			self::error("不支持从UNICODE LE转换到UTF-8或GB编码");
			fclose($fpr);
			return;
		}elseif($char1==chr(254) && $char2==chr(255)){//UNICODE BE
			self::error("不支持从UNICODE BE转换到UTF-8或GB编码");
			fclose($fpr);
			return;
		}else{//没有文件头,可能是GB或UTF-8
			if(rewind($fpr)===false){//回到文件开始部分,准备逐字节读取判断编码
				self::error($filename."文件指针后移失败");
				fclose($fpr);
				return;
			}

			while(!feof($fpr)){
				$char = fread($fpr,1);
				//对于英文,GB和UTF-8都是单字节的ASCII码小于128的值
				if(ord($char)<128)
					continue;

				//对于汉字GB编码第一个字节是110*****第二个字节是10******(有特例,比如联字)
				//UTF-8编码第一个字节是1110****第二个字节是10******第三个字节是10******
				//按位与出来结果要跟上面非星号相同,所以应该先判断UTF-8
				//因为使用GB的掩码按位与,UTF-8的111得出来的也是110,所以要先判断UTF-8
				if((ord($char)&224)==224) {
					//第一个字节判断通过
					$char = fread($fpr,1);
					if((ord($char)&128)==128) {
						//第二个字节判断通过
						$char = fread($fpr,1);
						if((ord($char)&128)==128) {
							$originEncoding = "UTF-8";
							break;
						}
					}
				}
				if((ord($char)&192)==192) {
					//第一个字节判断通过
					$char = fread($fpr,1);
					if((ord($char)&128)==128) {
						//第二个字节判断通过
						$originEncoding = "GB2312";
						break;
					}
				}
			}
		}

		if(strtoupper($out_charset)==$originEncoding) {
			self::info("文件".$filename."转码检查完成,原始文件编码".$originEncoding);
			fclose($fpr);
		}else {
			//文件需要转码
			$originContent = "";

			if($originEncoding == "UTF-8 WITH BOM") {
				//跳过三个字节,把后面的内容复制一遍得到utf-8的内容
				fseek($fpr,3);
				$originContent = fread($fpr,filesize($filename)-3);
				fclose($fpr);
			}elseif(rewind($fpr)!=false){//不管是UTF-8还是GB2312,回到文件开始部分,读取内容
				$originContent = fread($fpr,filesize($filename));
				fclose($fpr);
			}else{
				self::error("文件编码不正确或指针后移失败");
				fclose($fpr);
				return;
			}

			//转码并保存文件
			$content = iconv(str_replace(" WITH BOM","",$originEncoding),strtoupper($out_charset),$originContent);
			$fpw = fopen($filename,"w");
			fwrite($fpw,$content);
			fclose($fpw);

			if($originEncoding!="")
				self::info("对文件".$filename."转码完成,原始文件编码".$originEncoding.",转换后文件编码".strtoupper($out_charset));
			elseif($originEncoding=="")
				self::info("文件".$filename."中没有出现中文,但是可以断定不是带BOM的UTF-8编码,没有进行编码转换,不影响使用");
		}
	}
1234071
static boolean load(String path)
    {
        if (loadDat(path)) return true;
        // 从文本中载入并且尝试生成dat
        StringDictionary dictionary = new StringDictionary("=");
        if (!dictionary.load(path)) return false;
        TreeMap<String, Pinyin[]> map = new TreeMap<String, Pinyin[]>();
        for (Map.Entry<String, String> entry : dictionary.entrySet())
        {
            String[] args = entry.getValue().split(",");
            Pinyin[] pinyinValue = new Pinyin[args.length];
            for (int i = 0; i < pinyinValue.length; ++i)
            {
                try
                {
                    Pinyin pinyin = Pinyin.valueOf(args[i]);
                    pinyinValue[i] = pinyin;
                }
                catch (IllegalArgumentException e)
                {
                    logger.severe("读取拼音词典" + path + "失败，问题出在【" + entry + "】，异常是" + e);
                    return false;
                }
            }
            map.put(entry.getKey(), pinyinValue);
        }
        trie.build(map);
        logger.info("正在缓存双数组" + path);
        saveDat(path, trie, map.entrySet());
        return true;
    }
1326215
def decode(s):
    

    s = s.lower()
    r = ""
    t = ""
    for c in s:
        if c >= 'a' and c <= 'z':
            t += c
        elif c == ':':
            try:
                if t[-1] == 'u':
                    t = t[:-1] + u"\u00fc"
            except:
                pass
        else:
            if c >= '0' and c <= '5':
                tone = int(c) % 5
                if tone != 0:
                    m = re.search(u"[aoeiuv\u00fc]+", t)
                    if m is None:
                        t += c
                    elif len(m.group(0)) == 1:
                        t = t[:m.start(0)] + PinyinToneMark[tone][PinyinToneMark[0].index(m.group(0))] + t[m.end(0):]
                    else:
                        if 'a' in t:
                            t = t.replace("a", PinyinToneMark[tone][0])
                        elif 'o' in t:
                            t = t.replace("o", PinyinToneMark[tone][1])
                        elif 'e' in t:
                            t = t.replace("e", PinyinToneMark[tone][2])
                        elif t.endswith("ui"):
                            t = t.replace("i", PinyinToneMark[tone][3])
                        elif t.endswith("iu"):
                            t = t.replace("u", PinyinToneMark[tone][4])
                        else:
                            t += "!"
            r += t
            t = ""
    r += t
    return r