編程轉漢字
⑴ vb編程 阿拉伯數字轉換成大寫漢字 2位
建立文本框text1,text2按鈕command1復制以下代碼
Dima(10)AsInteger,b(10)AsString
PrivateSubCommand1_Click()
Dimx,yAsInteger
IfLen(Text1.Text)>0Then'當文本框中有數字時
IfLen(Text1.Text)=1Then'當文本框1中只有1位數字時
x=Val(Text1.Text)'x等於文本框中的數字
Text2.Text=b(x)'文本框2顯示該數字的大寫漢字
ElseIfLen(Text1.Text)=2Then'當文本框1中有2位數字時
x=Left(Text1.Text,1)'x等於第一位
y=Right(Text1.Text,1)'y等於第二位
Ifx=1Andy>0Then'判斷,當文本框中的數字在11到19之間時
Text2.Text=b(10)&b(y)
ElseIfx>1Andy>0Then'判斷,當文本框中的數字在21到99之間時
Text2.Text=b(x)&b(10)&b(y)
ElseIfx>0Andy=0Then'判斷,當文本框中的數字為10的倍數時
Text2.Text=b(x)&b(10)
EndIf
EndIf
EndIf
EndSub
PrivateSubForm_Load()
DimiAsInteger
Fori=0To10
a(i)=i
Nexti
b(0)="零"
b(1)="壹"
b(2)="貳"
b(3)="叄"
b(4)="肆"
b(5)="伍"
b(6)="陸"
b(7)="柒"
b(8)="捌"
b(9)="玖"
b(10)="拾"
Text1.FontSize=40
Text2.FontSize=40
Text1.MaxLength=2
Text2.Locked=True
EndSub
⑵ c語言編程如何輸出漢字
Windows XP與DOS是完全不同的兩種內核。Windows XP幾乎把DOS完全摒棄了。
而TC則是DOS時代的遺留物。
所以用TC編出來的程序在WINDOWS XP中運行時,許可權是非常有限的。特別是對屏幕的操作。所以畫點陣的方法是行不通的(更何況這個方法編出的程序也是很復雜的)。如果你用的是98以前的操作系統的話,用UCDOS就可以實現,但在XP中UCDOS已經不能用了。
如果想要用C語言編程時輸出漢字,可以用以下幾種方法:
1.最值得推薦的一種。摒棄TC,改用為WINDOWS編程設計的Visual C++,或者C++ Builder,lcc等。
用這幾種工具的話,在代碼中可以直接輸入漢字。編譯出來的是32位windows程序不存在兼容問題。
2.改用98以前的操作系統。
3.裝個虛擬機,在虛擬機中裝上DOS或者98。當然還要裝上UCDOS。然後,在其中用TC寫程序。
⑶ 如何用編程將輸入的數字轉換成漢字,如將10086換成中國移動。 需要下載哪種編程軟體,簡單易用就好,謝謝
我是VB.net 2010的~我會寫這樣的軟體
只要調用一個函數
執行以下代碼
Num = TextBox1.Text
Num = Num.Replace("10086", "中國移動")
TextBox2.Text = Num
========================================
模板就沒有了~我幫你做一個這樣的軟體
⑷ VB編程將阿拉伯數字轉化為漢字
准備Text1控制項,和Label1控制項
Private Sub Form_Load()
Text1 = ""
Label1.AutoSize = True
End Sub
Private Sub Text1_Change()
Dim strCh As String, temp As String, i As Integer
strCh = "零一二三四五六七八九"
temp = ""
For i = 1 To Len(Text1)
temp = temp & Mid(strCh, CInt(Mid(Text1, i, 1)) + 1, 1)
Next
Label1.Caption = temp
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case vbKeyBack
Text1 = ""
Case Is < Asc("0")
KeyAscii = 0
Case Is > Asc("9")
KeyAscii = 0
End Select
End Sub
⑸ 如何用C++編程Unicode轉中文
UNICODE 在C++里用wchar_t表示, 如: wchar_t wc = L'簡' 而wchar_t在一些編譯器里被定義為無符號短整形 short 所以UNICODE (一般情況下)就是一個整數. 可以這樣定義一個wchar_t wchar_t wc2 = 31616; wcout<< wc << " " << wc2 << endl; 的結果就是輸出兩個 簡. 只要腦子里想UNICODE (一般情況下)就是 unsigned short, 就會理解.
⑹ 編程中,如何將拼音轉換成文字
在ios開發中經常碰到做通訊錄需要將漢字轉成拼音的情況,以下就是我把漢字轉成拼音的方法。
把代碼給你貼出來!
+ (NSString *)transform:(NSString *)chinese
{
NSMutableString *pinyin = [chinese mutableCopy];
CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, , NO);
CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, , NO);
NSLog(@"%@", pinyin);
return [pinyin uppercaseString];
}
⑺ php語言編程,這些字元怎樣轉換為漢字
你可以嘗試轉換一下字元編碼,一般常用的是UTF-8的。望採納
⑻ 如何用c語言將數字轉換成漢字
你花了3天都做了什麼呢?!拿出來看看
分還那麼低
⑼ java編程 數字轉換成漢字
我自己寫的,匆忙寫的。我有時間再改進改進。
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Stack;
/*
* 本程序
*/
public class Transfer {
public Stack<Integer> transfer(int n){
Stack<Integer> st = new Stack<Integer>();
int division = 0; //余數
while(n>=10){
division = n%10;
st.push(division);
n = n/10;
}
st.push(n); //將最高位壓棧
return st;
}
public static void main(String[]args){
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String in = "";
try {
in = reader.readLine();
} catch (IOException e) {
e.printStackTrace();
}
int n = 0;
try{
n = Integer.parseInt(in);
} catch(NumberFormatException e){
e.printStackTrace();
}
Transfer tf = new Transfer();
Stack<Integer> s = tf.transfer(n);
/*
while(!s.empty()){
System.out.print(s.pop()); //測試語句
}
*/
HashMap<Integer, String> hp1 = new HashMap<Integer, String>(); //第一個映射表
hp1.put(0, "零"); //根據所在位的數值與中文對應
hp1.put(1, "一");
hp1.put(2, "二");
hp1.put(3, "三");
hp1.put(4, "四");
hp1.put(5, "五");
hp1.put(6, "六");
hp1.put(7, "七");
hp1.put(8, "八");
hp1.put(9, "九");
HashMap<Integer, String> hp2 = new HashMap<Integer, String>(); //第二個映射表
hp2.put(2, "十"); //根據所在位數,與中文對應
hp2.put(3, "百");
hp2.put(4, "千");
hp2.put(5, "萬");
hp2.put(6, "十萬");
hp2.put(7, "百萬");
hp2.put(8, "千萬");
hp2.put(9, "億");
//System.out.println(s.size());
String out = "";
while(!s.isEmpty()){
int temp = s.pop();
if(s.size()==0){
if(temp !=0){
out = out + hp1.get(temp);
}
}
else{
if(temp==0){
out = out + hp1.get(temp);
}
else{
out = out + hp1.get(temp) + hp2.get(s.size()+1);
}
}
}
System.out.println(out);
}
}
對於如2008之類的數,輸出的是二千零零八,還需要加以判斷,我再去處理下。
還有涉及萬以上的數,比如
123456
輸出的是一十萬二萬三千四百五十六,也必須增加判斷。
⑽ 請問如何用C語言實現漢字,和Unicode編碼的轉換
字轉換:wctomb、mbtowc,wc 指 Wide charactor,mb 指 Multi-byte。
字元串轉換:wcstombs、mbstowcs,wcs 和 mbs 的 s 指 string。
這 4 個函數是 C 標准函數庫函數中的。如果只是在 Windows 平台下編程,可直接調用 Windows API 函數 WideCharToMultiByte 和 MultiByteToWideChar 實現。但是如果調用標准庫函數的話,在 Linux 下也是有效的。調用標准庫函數,首先必須包含 locale.h 並調用 setlocale(LC_ALL, "") 後才能正確轉換。Windows 下的 Multi-byte 是 ANSI 編碼的,Wide charactor 是 Unicode (UTF-16) 編碼,而 Linux 下的 Multi-byte 是 UTF-8 編碼的,Wide charactor 是 Unicode (UTF-32) 編碼。
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
int main(void)
{
char str[12];
wchar_t wstr[] = { 0x52B3, 0x788C, 0 };
setlocale(LC_ALL, "");
wcstombs(str, wstr, sizeof(str)/sizeof(char));
printf("%s", str);
return 0;
}