C + + to get the first letter of Chinese pinyin

Source: Internet
Author: User

1#include <stdint.h>2#include <stdio.h>3#include <ctype.h>4#include <string.h>5 6 BOOLbetween (uint32_t start,uint32_t end,uint32_t aim);7 CharGet_first_letter (wchar_t wchar);8 voidGet_first_letters (Const Char*szchinese,CharPiyinbuf[],Constuint32_t maxbuflen,uint32_t &Piyinbuflen);9 Ten  One int32_t Main () A { -     Charbuf[1024x768] = {0}; -uint32_t len =0; the     Const Char*szchinese ="qaz123 get Chinese pinyin"; -Get_first_letters (Szchinese,buf,1024x768, Len); -printf"%s\n", buf); -     return 0; + } -  + voidGet_first_letters (Const Char*szchinese,CharPiyinbuf[],Constuint32_t maxbuflen,uint32_t &Piyinbuflen) A { atuint8_t chr[3]; -Piyinbuflen =0; -uint32_t Chineselen =strlen (Szchinese); -      for(Uint32_t i =0; I < Chineselen && Piyinbuflen < Maxbuflen; ++i) -     { -uint8_t C =Szchinese[i]; in         //Exclude Askii Code -         if(Isascii (c)) to         { +piyinbuf[piyinbuflen++] =C; -         } the         Else *         { $chr[0] =Szchinese[i];Panax Notoginsengchr[1] = szchinese[++i]; -chr[2] =0; thewchar_t WCHR =0; +WCHR = (chr[0] &0xFF) <<8; AWCHR |= (chr[1] &0xFF); thepiyinbuf[piyinbuflen++] =ToUpper (Get_first_letter (WCHR)); +         } -     } $ } $  - BOOLbetween (wchar_t start,wchar_t end,wchar_t aim) - { the     if(Start <= aim && Aim <=end) -     {Wuyi         return true; the     } -     return false; Wu } -  About CharGet_first_letter (wchar_t wchar) $ { -     if(Between (0xb0a1,0xb0c4, WCHAR))return  'a'; -     if(Between (0xb0c5,0xb2c0, WCHAR))return  'b'; -     if(Between (0xb2c1,0xb4ed, WCHAR))return  'C'; A     if(Between (0xb4ee,0xb6e9, WCHAR))return  'D'; +     if(Between (0xb6ea,0XB7A1, WCHAR))return  'e'; the     if(Between (0XB7A2,0xb8c0, WCHAR))return  'F'; -     if(Between (0xb8c1,0XB9FD, WCHAR))return  'g'; $     if(Between (0xb9fe,0xbbf6, WCHAR))return  'h'; the     if(Between (0xbbf7,0xbfa5, WCHAR))return  'J'; the     if(Between (0xbfa6,0xc0ab, WCHAR))return  'k'; the     if(Between (0xc0ac,0xc2e7, WCHAR))return  'L'; the     if(Between (0xc2e8,0xc4c2, WCHAR))return  'm'; -     if(Between (0xc4c3,0xc5b5, WCHAR))return  'N'; in     if(Between (0xc5b6,0XC5BD, WCHAR))return  'o'; the     if(Between (0xc5be,0xc6d9, WCHAR))return  'P'; the     if(Between (0xc6da,0xc8ba, WCHAR))return  'Q'; About     if(Between (0XC8BB,0xc8f5, WCHAR))return  'R'; the     if(Between (0xc8f6,0xcbf0, WCHAR))return  's'; the     if(Between (0xCBFA,0xcdd9, WCHAR))return  'T'; the     if(Between (0xCDDA,0XCEF3, WCHAR))return  'W'; +     if(Between (0XCEF4,0xd188, WCHAR))return  'x'; -     if(Between (0xd1b9,0xd4d0, WCHAR))return  'y'; the     if(Between (0xd4d1,0xd7f9, WCHAR))return  'Z';Bayi     return  ' /'; the}

C + + to get the first letter of Chinese pinyin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.