Home Database Mysql Tutorial 获取中文名称的首字母

获取中文名称的首字母

Jun 07, 2016 pm 02:54 PM
Chinese name letter Pinyin Obtain

用于获取中文名称的首字母 拼音 SQL Server CREATE FUNCTION getPinYin (@str varchar(500) = '') RETURNS varchar(500) AS /*-------------------用于获取中文名称的首字母---------------------------------*/BEGIN Declare @strlen int, @return varchar(5

用于获取中文名称的首字母 拼音 SQL Server
CREATE FUNCTION  getPinYin (@str varchar(500) = '')  
RETURNS varchar(500)  AS  

/*-------------------用于获取中文名称的首字母---------------------------------*/
BEGIN 
Declare @strlen int,
  @return varchar(500),
  @ii int,
  @c char(1),
  @chn nchar(1)
 --//初始化变量 
	 Declare @pytable table(
	 chn char(2) COLLATE Chinese_PRC_CS_AS NOT NULL,
	 py char(1) COLLATE Chinese_PRC_CS_AS NULL,
	 PRIMARY KEY (chn) 
	   )
	 insert into @pytable values('吖', 'A')
	 insert into @pytable values('八', 'B')
	 insert into @pytable values('嚓', 'C')
	 insert into @pytable values('咑', 'D')
	 insert into @pytable values('妸', 'E')
	 insert into @pytable values('发', 'F')
	 insert into @pytable values('旮', 'G')
	 insert into @pytable values('铪', 'H')
	 --insert into @pytable values('丌', 'I')
	 insert into @pytable values('丌', 'J')
	 insert into @pytable values('咔', 'K')
	 insert into @pytable values('垃', 'L')
	 insert into @pytable values('嘸', 'M')
	 insert into @pytable values('拏', 'N')
	 insert into @pytable values('噢', 'O')
	 insert into @pytable values('妑', 'P')
	 insert into @pytable values('七', 'Q')
	 insert into @pytable values('呥', 'R')
	 insert into @pytable values('仨', 'S')
	 insert into @pytable values('他', 'T')
	 --insert into @pytable values('屲', 'U')
	 --insert into @pytable values('屲', 'V')
	 insert into @pytable values('屲', 'W')
	 insert into @pytable values('夕', 'X')
	 insert into @pytable values('丫', 'Y')
	 insert into @pytable values('帀', 'Z')

 select @strlen = len(@str), @return = '', @ii = 0 
 --//循环整个字符串,用拼音的首字母替换汉字 
 while @ii < @strlen 
 begin
  select @ii = @ii + 1, @chn = substring(@str, @ii, 1)
     if @chn > 'z' --//检索输入的字符串中有中文字符
	   SELECT @c = max(py)
	   FROM @pytable
	   where chn <= @chn
    else
         set @c=@chn
 
  set @return=@return+@c 
 end
 return @return
END


Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1670
14
PHP Tutorial
1274
29
C# Tutorial
1256
24
3 tips to easily customize your Mac computer name, host name and Bonjour name 3 tips to easily customize your Mac computer name, host name and Bonjour name Mar 06, 2024 pm 12:20 PM

Many Mac users tend to keep the default name of their device and may never consider changing it. Many people choose to stick with the name from the initial setup, such as "Johnny's MacBook Air" or simply "iMac." Learning how to change the name of your Mac is a very useful skill, especially when you have multiple devices, as it can help you quickly distinguish and manage them. Next, we will teach you step by step how to change the computer name, host name and Bonjour name (local host name) in macOS system. Why should you change your Mac name? Changing the name of your Mac can not only show your personality, but also help improve the user experience: Personalize your Mac: The default name may not be to your taste, change it to a name you like.

How to set Chinese in Call of Duty: Warzone mobile game How to set Chinese in Call of Duty: Warzone mobile game Mar 22, 2024 am 08:41 AM

Call of Duty Warzone is a newly launched mobile game. Many players are very curious about how to set the language of this game to Chinese. In fact, it is very simple. Players only need to download the Chinese language pack, and then You can modify it after using it. The detailed content can be learned in this Chinese setting method introduction. Let us take a look together. How to set the Chinese language for the mobile game Call of Duty: Warzone 1. First enter the game and click the settings icon in the upper right corner of the interface. 2. In the menu bar that appears, find the [Download] option and click it. 3. Select [SIMPLIFIEDCHINESE] (Simplified Chinese) on this page to download the Simplified Chinese installation package. 4. Return to the settings

An effective way to fix Chinese garbled characters in PHP Dompdf An effective way to fix Chinese garbled characters in PHP Dompdf Mar 05, 2024 pm 04:45 PM

Title: An effective way to repair Chinese garbled characters in PHPDompdf. When using PHPDompdf to generate PDF documents, garbled Chinese characters are a common problem. This problem usually stems from the fact that Dompdf does not support Chinese character sets by default, resulting in Chinese content not being displayed correctly. In order to solve this problem, we need to take some effective ways to fix the Chinese garbled problem of PHPDompdf. 1. Use custom font files. An effective way to solve the problem of Chinese garbled characters in Dompdf is to use

How to display Chinese characters correctly in PHP Dompdf How to display Chinese characters correctly in PHP Dompdf Mar 05, 2024 pm 01:03 PM

How to display Chinese characters correctly in PHPDompdf When using PHPDompdf to generate PDF files, it is a common challenge to encounter the problem of garbled Chinese characters. This is because the font library used by Dompdf by default does not contain Chinese character sets. In order to display Chinese characters correctly, we need to manually set the font of Dompdf and make sure to select a font that supports Chinese characters. Here are some specific steps and code examples to solve this problem: Step 1: Download the Chinese font file First, we need

Setting up Chinese with VSCode: The Complete Guide Setting up Chinese with VSCode: The Complete Guide Mar 25, 2024 am 11:18 AM

VSCode Setup in Chinese: A Complete Guide In software development, Visual Studio Code (VSCode for short) is a commonly used integrated development environment. For developers who use Chinese, setting VSCode to the Chinese interface can improve work efficiency. This article will provide you with a complete guide, detailing how to set VSCode to a Chinese interface and providing specific code examples. Step 1: Download and install the language pack. After opening VSCode, click on the left

How to set Excel table to display Chinese? Excel switching Chinese operation tutorial How to set Excel table to display Chinese? Excel switching Chinese operation tutorial Mar 14, 2024 pm 03:28 PM

Excel spreadsheet is one of the office software that many people are using now. Some users, because their computer is Win11 system, so the English interface is displayed. They want to switch to the Chinese interface, but they don’t know how to operate it. To solve this problem, this issue The editor is here to answer the questions for all users. Let’s take a look at the content shared in today’s software tutorial. Tutorial for switching Excel to Chinese: 1. Enter the software and click the "File" option on the left side of the toolbar at the top of the page. 2. Select "options" from the options given below. 3. After entering the new interface, click the “language” option on the left

balatro settings Chinese method balatro settings Chinese method Mar 07, 2024 pm 09:10 PM

The default language of the balatro game is English, but players can set the language to Chinese in Steam. Some players still don’t know how to set it. Here is how to set balatro to Chinese. How to set up balatro in Chinese 1. First open Steam, click on the library, find balatro, right-click and select properties. 2. You can see the language in the properties interface, click to enter the language setting interface. 3. Players can set the language of the game to Simplified Chinese or other languages. 4. Afterwards, players need to restart Steam, and then enter the game to see that it is already in Chinese. The above is how to set Chinese in balatro. It is relatively simple. Players can try it.

Will wwe2k24 have Chinese? Will wwe2k24 have Chinese? Mar 13, 2024 pm 04:40 PM

"WWE2K24" is a racing sports game created by Visual Concepts and was officially released on March 9, 2024. This game has been highly praised, and many players are eagerly interested in whether it will have a Chinese version. Unfortunately, so far, "WWE2K24" has not yet launched a Chinese language version. Will wwe2k24 be in Chinese? Answer: Chinese is not currently supported. The standard version of WWE2K24 in the Steam Chinese region is priced at 199 yuan, the deluxe version is 329 yuan, and the commemorative edition is 395 yuan. The game has relatively high configuration requirements, and there are certain standards in terms of processor, graphics card, or running memory. Official recommended configuration and minimum configuration introduction:

See all articles