using System; using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions; namespace CommonClass.Util { /// <summary> /// 汉字转拼音类 /// </summary> public class PinYin { private static readonly int[] PyValue = new int
按照汉字的拼音排序,用的比较多是在人名的排序中,按照姓氏的拼音字母,从A到Z排序: 如果存储姓名的字段采用的是GBK字符集,那就好办了,因为GBK内码编码时本身就采用了拼音排序的方法(常用一级汉字3755个采用拼音排序,二级汉字就不是了,但考虑到人名等都是常用汉字,因此只是针对一级汉字能正确排序也够用了). 直接在查询语句后面 添加 order by name asc; 查询结果按照姓氏的升序排序: 如果存储姓名的字段采用的是 utf8字符集,需要在排序的时候对字段进行转码:对于的代码是 or
/* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://w
按照汉字的拼音排序,用的比较多是在人名的排序中,按照姓氏的拼音字母,从A到Z排序: 如果存储姓名的字段采用的是GBK字符集,那就好办了,因为GBK内码编码时本身就采用了拼音排序的方法(常用一级汉字3755个采用拼音排序,二级汉字就不是了,但考虑到人名等都是常用汉字,因此只是针对一级汉字能正确排序也够用了). 直接在查询语句后面 添加 order by name asc; 查询结果按照姓氏的升序排序: 如果存储姓名的字段采用的是 utf8字符集,需要在排序的时候对字段进行转码:对于的代码是 or
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Common { //Author:GaoBingBing public static class ChineseToPinYin { private static readonly Dictionary<int, string> CodeCollections = new Dictionary<i