c#提出中文首字母
/// <summary>
/// 获取中文字符串的首字母
/// </summary>
/// <param name="strText"></param>
/// <returns></returns>
public static string GetChineseSpell(string strText)
{
int len = strText.Length;
string myStr = "";
for (int i = ; i < len; i++)
{
myStr += getSpell(strText.Substring(i, ));
}
return myStr;
} /// <summary>
/// 获取单个中文的首字母
/// </summary>
/// <param name="cnChar"></param>
/// <returns></returns>
private static string getSpell(string cnChar)
{
byte[] arrCN = Encoding.Default.GetBytes(cnChar);
if (arrCN.Length > )
{
int area = (short)arrCN[];
int pos = (short)arrCN[];
int code = (area << ) + pos;
int[] areacode = { , , , , , , , , , , , , , , , , , , , , , , , , , }; for (int i = ; i < ; i++)
{
int max = ;
if (i != )
{
max = areacode[i + ];
}
if (areacode[i] <= code && code < max)
{
return Encoding.Default.GetString(new byte[] { (byte)( + i) });
}
}
return "*";
}
else return cnChar;
}
c#提出中文首字母的更多相关文章
- php按照中文首字母排序
1> 网络上很多php的工具类可以将汉字转为拼音: 2> 将拼音进行排序即可 另一种则是类似mysql转码方式: 1 foreach ($array as $key=>$value) ...
- mysql排序的中文首字母排序和自定义排序
select * FROM organ_new where city_code = 'SZ0755' and organ_type = 'H' and state = '1' ORDER BY FIE ...
- PHP获取中文首字母的函数
PHP获取中文首字母的函数 <?php header("Content-type: text/html; charset=utf-8"); function getFirst ...
- Java获取中文拼音、中文首字母缩写和中文首字母
获取中文拼音(如:广东省 -->guangdongsheng) /** * 得到中文全拼 * @param src 需要转化的中文字符串 * @return */ public static S ...
- oc中文首字母排序
oc中文首字母排序 NSArray *arr2=@[@"小雨",@"安安",@"小风",@"荣荣",@"张涛& ...
- js中文首字母数组排序
js中文首字母数组排序 数组的排序js算法: var Pinyin = (function() { var Pinyin = function(ops) { this.initialize(ops); ...
- Java中实现对集合中对象按中文首字母排序
有一个person对象如下: public class Person { private String id;private String nam; } 一个list集合如下: List<Emp ...
- php里获取第一个中文首字母并排序
需求里结算首页需要按门店的首字母A-Z排序.我的数据结构原本是这样的: Array ( [0] => Array ( [sid] => 2885842 [recetcstoredpay] ...
- 关于java中实现在oracle数据库中实现对中文首字母进行排序的解决方案
首先介绍Oracle 9i新增加的一个系统自带的排序函数 1.按首字母排序 在oracle9i中新增了按照拼音.部首.笔画排序功能.设置NLS_SORT值 SCHINESE_RADICAL_M ...
随机推荐
- GDKOI2015
problems http://gdoi.sysu.edu.cn/wp-content/uploads/2015/03/GDKOI-2015-day1.pdf http://gdoi.sysu.edu ...
- OpenXML - 如何导出List<DataModel>到Excel -- Part 1
最近这几天研究OpenXML: 这是Open XML的一些介绍: Open XML 介绍:http://baike.baidu.com/view/1201978.htm 下载:http://www.m ...
- swift 自定义导航栏颜色
func setNavigationApperance(){ //自定义导航栏颜色 [self.navigationController?.navigationBar.barTintColor = U ...
- c/c++ 复习基础要点01-const指针、指针函数 函数指针、new/delete与malloc/free区别与联系
1. 引用本身是有指针实现的:引用为只读指针 例子: int d=123; int& e=d; //引用 int * const e=d; //只读指针,e指向d,不可修改e指 ...
- SWTBOK測试实践系列(4) -- 软件測试技术的黑白之道
白盒測试和黑盒測试往往是项目中最受争议的两种測试类型,每一个人偏爱各不同.现实生活中行业人员大多喜欢白盒測试而忽视黑盒測试,那么项目中又应该怎样平衡这两类測试呢?我们先来看两个案例. 案例一: 某移动 ...
- Git diff (---和+++具体解释)
如果两个文件相似度很高,那么上下文格式的diff,将显示大量重复的内容,很浪费空间.1990年,GNU diff率先推出了"合并格式"的diff,将f1和f2的上下文合并在一起显示 ...
- Qt Label show Images
第一.我们需要让QLabel的大小不因为图片的大小变化而变化,可以用下面语句实现 ui->imageLabel->setSizePolicy(QSizePolicy::Ignored, Q ...
- 解决android自带textview右侧文字不能对齐的问题
package com.sixin.view; import android.content.Context; import android.graphics.Canvas; import andro ...
- Python安装后在CMD命令行下出现“应用程序无法启动.............”问题
问题存在之一:系统是刚刚重做的精简版服务器系统(阉割版) AN就是在阿里云上刚开的Windows Server 2008 系统上碰到的 吓尿了都 症状: 正常安装python环 ...
- 调试EF源码
在解决方案中添加下载好的EF的源码的引用 在新建项目中添加程序集的引用 添加配置文件中的节点 测试 获取程序集的公钥标记: 使用sn.exe命令 使用reflector