Java字串的大小寫轉換與Locale
涉及到多國語言的時候,需要呼叫Locale版本的的toLowerCase(Locale)和toUpperCase(Locale)方法。
示例:
import java.util.Locale; public class StringLocale { public static void main(String[] args) { String lower_abcdefg = "abcdefghijklmnopqrstuvwxyz"; String upper_abcdefg = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; Locale[] locales = Locale.getAvailableLocales(); for (Locale locale : locales) { System.out.print(locale.toString() + "\t"); if (lower_abcdefg.toUpperCase(locale).equals(upper_abcdefg)) { System.out.println("match"); } else { System.out.println("not match"); } } } }
以上程式碼的輸出結果:
ms_MY match ar_QA match is_IS match fi_FI match pl match en_MT match it_CH match nl_BE match ar_SA match ar_IQ match es_PR match es_CL match fi match de_AT match da match en_GB match es_PA match sr match ar_YE match mk_MK match mk match en_CA match vi_VN match nl_NL match es_US match zh_CN match es_HN match en_US match fr match th match ar match ar_MA match lv match de match in_ID match hr match en_ZA match ko_KR match ar_TN match in match ja match sr_RS match be_BY match zh_TW match ar_SD match pt match is match ja_JP_JP_#u-ca-japanese match es_BO match ar_DZ match ms match es_AR match ar_AE match fr_CA match sl match es match lt_LT match sr_ME_#Latn match ar_SY match ru_RU match fr_BE match es_ES match bg match iw_IL match sv match en match iw match da_DK match es_CR match zh_HK match zh match ca_ES match th_TH match uk_UA match es_DO match es_VE match pl_PL match ar_LY match ar_JO match it match uk match hu_HU match ga match es_GT match es_PY match bg_BG match hr_HR match sr_BA_#Latn match ro_RO match fr_LU match no match lt match en_SG match es_EC match sr_BA match es_NI match sk match ru match mt match es_SV match nl match hi_IN match et match el_GR match sl_SI match it_IT match ja_JP match de_LU match fr_CH match mt_MT match ar_BH match sq match vi match sr_ME match pt_BR match no_NO match el match de_CH match zh_SG match ar_KW match ar_EG match ga_IE match es_PE match cs_CZ match tr_TR not match cs match es_UY match en_IE match en_IN match ar_OM match sr_CS match ca match be match sr__#Latn match ko match sq_AL match pt_PT match lv_LV match sr_RS_#Latn match sk_SK match es_MX match en_AU match no_NO_NY match en_NZ match sv_SE match ro match ar_LB match de_DE match th_TH_TH_#u-nu-thai match tr not match es_CO match en_PH match et_EE match el_CY match hu match fr_FR match
相關推薦
Java字串的大小寫轉換與Locale
涉及到多國語言的時候,需要呼叫Locale版本的的toLowerCase(Locale)和toUpperCase(Locale)方法。 示例: import java.util.Locale; public class StringLocale { public
Java字串大小寫轉換
.toLowerCase();//轉成小寫 .toUpperCase();//轉成大寫 例: String str = "abcABCdefDEF"; String Upstr = str.to
java中字串大小寫轉換
JAVA中String類提供了轉大寫的方法toUpperCase()和轉小寫的方法toLowerCase() 使用說明: String a = "ITXIAOBAI"; system.out.println(a.toLowerCase());//itxiaobai String
linux bash shell:最方便的字串大小寫轉換(lowercase/uppercase conversion)
關於字串大小寫轉換,是寫 linux 指令碼經常乾的事兒,所以總想找個方便的方法讓我少打點字兒,搜尋國內的中文資源,網上也能找到很多關於這個帖子,介紹的方法都差不多,用typeset是最簡單的方法了,但我覺得還是不夠簡單,因為需要多定義一個變數。 google上找到這個stackov
java 字串的比較與合併操作
1.字元的排序 2 種方法 public class Sort { public static void main(Stri
[Swift]字串大小寫轉換,轉換同時實現本地化或設定語言環境
在NSString中提供了3種字串大小寫轉換方式:1. 轉換字串大小寫2. 轉換字串大小寫,並實現本地化3. 轉換字串大小寫,並設定語言環境。 一、 轉換字串大小寫如果只是想單純的將字串進行大小寫轉換,可以使用NSString中的3個屬性實現,Lowercased-將字母轉換為小寫Uppercased-將字
理解Java字串常量池與intern()方法
閱讀目錄 Java記憶體區域 兩種建立方式在記憶體中的區別 解釋開頭的例子 intern()方法 參考資料 String s1 = "Hello"; String s2 = "Hello"; String s3 = "Hel"
java字串的構造與使用
String可以用String c=" ";進行構造,也可以用 StringBuilder c= new StringBuilder ();進行構造,最後再轉化為String,使用toString()。 然而,二者的效率確實有著10倍這樣的差異,所以構造字串建議使用StringBu
Java字串操作及與C#字串操作的不同
每種語言都會有字串的操作,因為字串是我們平常開發使用頻率最高的一種型別。今天我們來聊一下Java的字串操作及在某些具體方法中與C#的不同,對於需要熟悉多種語言的人來說,作為一種參考。進行誡勉 首先,什麼是字串? 字串是字元的序列,是作為一種物件而存在。說的直白點,字串就是一些字元的組合,從而構成字串,例如
python字串大小寫轉換
str = "www.w3cSChool.cn"print(str.upper()) # 把所有字元中的小寫字母轉換成大寫字母print(str.lower()) # 把所有字元中的大寫字母轉換成小寫字母print(str.capitalize()) # 把第一個字母轉化為大寫字母,其餘小寫print(str
php 字串大小寫轉換
mb_convert_case mb_convert_case — 對字串進行大小寫轉換 mb_convert_case ( string $str , int $mode [, string $encoding = mb_internal_encoding() ] ) 1 對
C++中字串大小寫轉換
字串大小寫轉換 #include <iostream> #include <string> #include <algorithm> using namespace std; int main(){ string str1="he
python字串大小寫轉換及list和str轉換
1.字串的編碼 問題一:能不能像C語言那樣用 ch = ch +32 來把大寫的字元程式設計小寫的? 可以的,如下所示: s = chr(ord(s) - 32) 先用ord()函式獲取字元的整數表示,chr()函式把編碼轉換為對應的字元 python使用
java字串編碼轉換及在tomcat中的應用
最近在正式環境中手機訪問系統時,中文都會出現亂碼的情況。順帶研究一下字符集的問題。字串編碼轉換java檔案編譯時,JVM按照檔案的編碼方式解析成字元,然後轉換為unicode格式的位元組陣列。 那麼不論原始碼檔案是什麼格式,同樣的字串,最後得到的unicode位元組陣列是完全
PHP的strtolower()和strtoupper()函式在安裝非中文系統的伺服器下可能會導致將漢字轉換為亂碼,請寫兩個替代的函式實現相容Unicode文字的字串大小寫轉換
最近看到一個比較有意思的問題,如題。 首先檢視php函式的實現原始碼,以strtolower為例,原始碼如下 c = (unsigned char *)s; e = c+len; // 遍歷s,逐個變為小寫 while (c < e) { *c
php 字串大小寫轉換
mb_convert_case mb_convert_case — 對字串進行大小寫轉換 mb_convert_case ( string $str , int $mode [, string $encoding = mb_internal_encodi
java字串大小寫轉化
toLowerCase()方法將String轉換為小寫。如果字串中沒有應該被轉換的字元,則將原字串返回,否則返回一個新的字串。 語法:str.toLowerCase() toUpperCase()方法將Srtring轉換為大寫。如果字串中沒有應該轉換的字元,則將原字串返回,
Python time模組,時間戳,時間元祖,字串相互轉換與時間加減
獲取時間戳import time timestamp = time.time() print(timestamp) 1531366876.4177334時間戳是指格林威治時間1970年01月01日00
12、Python 中 字串大小寫轉換
簡單總結下Python中字串大小寫轉換,最後有個處理列表的方法感覺有點意思 a = 'hello python' #都是小寫 b = 'Hello python' #第一個字母大寫 c =
Python 字串大小寫轉換,值域範圍
clip,設定值域範圍, a=[[1,2],[3,4]] b=np.clip(a,1,3) print(b) Python 字串大小寫轉換 以下程式碼演示瞭如何將字串轉換為大寫字母,或者將字串轉為小寫字母等: # Filename : test.p