unicode-string

Is it possible to write a Swift function that replaces only part of an extended grapheme cluster like 👩‍👩‍👧‍👧?

核能气质少年 提交于 2019-12-04 09:07:22
问题 I want to write a function that could be used like this: let 👩‍👩‍👧‍👦 = "👩‍👩‍👧‍👧".replacingFirstOccurrence(of: "👧", with: "👦") Given how odd both this string and Swift's String library are, is this possible in Swift? 回答1: Using the range(of:options:range:locale:) the solution became quite concise: extension String { func replaceFirstOccurrence(of searchString: String, with replacementString: String) -> String { guard let range = self.range(of: searchString, options: .literal) else { return

StrRev() Dosent Support UTF-8

旧巷老猫 提交于 2019-12-04 04:37:57
I'm trying to make a code that replace Arabic text to be supported in non Arabic supported programs in that i will be need to reverse the text after replace but its shows some garbage stuff instead of the wanted result Here Is The Code : <?php $string = "اهلا بك"; echo "$string <br>"; $Reversed = strrev($string); echo "<br><b>After Reverse</b><br><br>"; echo "<br> $Reversed"; ?> Result : اهلا بك After Reverse �٨� �؄ه٧ I need it to be the way it is but reversed ? not GARBAGE !! in order to make that strrev() support UTF-8 you need to use this Function function utf8_strrev($str){ preg_match_all(

Get “actual” length of string in Unicode characters

拜拜、爱过 提交于 2019-12-03 06:54:08
given a character like " ✮ " ( \xe2\x9c\xae ), for example, can be others like " Σ ", " д " or " Λ ") I want to find the "actual" length that character takes when printed onscreen for example len("✮") len("\xe2\x9c\xae") both return 3, but it should be 1 You may try like this: unicodedata.normalize('NFC', u'✮') len(u"✮") UTF-8 is an unicode encoding which uses more than one byte for special characters. Check unicodedata.normalize() Simon Richter My answer to a similar question : You are looking for the rendering width from the current output context. For graphical UIs, there is usually a

iOS: handling HTTP request's unicode characters

若如初见. 提交于 2019-12-02 17:43:20
问题 When I NSLog HTTP requests response string, it appears as "ãÃÂïãÃâ¬ÃÂãÃÂÃâãÃÂ" and something different appears on UILabel but not the same as I expect in Japanese/Chinese format. I am using ASIHTTPRequest and as mentioned here I have set response encoding to NSUTF8StringEncoding(server uses UTF-8 same) but it didn't help. Could someone please tell me how to support unicode character in my App? Thanks. - (void)getData { ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL

Removing all Emojis from Text

穿精又带淫゛_ 提交于 2019-12-02 00:24:28
问题 This question has been asked here Python : How to remove all emojis Without a solution, I have as step towards the solution. But need help finishing it off. I went and got all the emoji hex code points from the emoji site: https://www.unicode.org/emoji/charts/emoji-ordering.txt I then read in the file like so: file = open('emoji-ordering.txt') temp = file.readline() final_list = [] while temp != '': #print(temp) if not temp[0] == '#' : utf_8_values = ((temp.split(';')[0]).rstrip()).split(' ')

Writing ANSI string to Unicode file over FTP

三世轮回 提交于 2019-12-01 21:56:45
问题 I have the following Visual Basic 6.0 function which writes an ANSI string to a new file over FTP. I would like it to write the file as UTF-16LE. Is there any good way to do that within this following method? Public Sub writeToFile(ByVal FTPServer As String _ , ByVal userName As String _ , ByVal password As String _ , ByVal contents As String _ , ByVal destinationFile As String) Dim hFile As Long Dim lCount As Long inetOpen inetConnect FTPServer, userName, password hFile = apiFtpOpenFile(m

How do i construct a WideString with a diacratic in a non-unicode Delphi version?

烂漫一生 提交于 2019-12-01 21:32:00
问题 i am trying to construct a (test) WideString of: á (U+00E1 Small Letter Latin A with acute) but using it's decomposed form: LATIN SMALL LETTER A (U+0061) COMBINING ACUTE ACCENT (U+0301) So i have the code fragment: var test: WideString; begin test := #$0061#$0301; MessageBoxW(0, PWideChar(test), 'Character with diacratic', MB_ICONINFORMATION or MB_OK); end; Except it doesn't appear to work: This could be a bug in MessageBox, but i'm going to go ahead and say that it's more likely the bug is

Removing all Emojis from Text

守給你的承諾、 提交于 2019-12-01 20:48:09
This question has been asked here Python : How to remove all emojis Without a solution, I have as step towards the solution. But need help finishing it off. I went and got all the emoji hex code points from the emoji site: https://www.unicode.org/emoji/charts/emoji-ordering.txt I then read in the file like so: file = open('emoji-ordering.txt') temp = file.readline() final_list = [] while temp != '': #print(temp) if not temp[0] == '#' : utf_8_values = ((temp.split(';')[0]).rstrip()).split(' ') values = ["u\\"+(word[0]+((8 - len(word[2:]))*'0' + word[2:]).rstrip()) for word in utf_8_values]

Arabic characters don't show in excel VBA code

↘锁芯ラ 提交于 2019-12-01 11:08:26
I can't write arabic strings in VBA code in excel, it shows as weird characters. Tried it on many machines with excel 2013 or 2010, on windows 8 or windows 7, with or without arabic proofing tools installed. Arabic language is already installed on all machines, system locale is arabic. There's no problem typing arabic characters on excel worksheets or even MS word but not in VBA code. Please help. in VB Editor: - 1- click tools 2- Select Options... 3- click Editor Fofmat 4- Change font to(Courier New (Arabic)) 5- click OK now you can write in both English and Arabic I hope this will solve your

Python - BeautifulSoup html parsing handle gbk encoding poorly - Chinese webscraping problem

妖精的绣舞 提交于 2019-12-01 11:00:48
I have been tinkering with the following script: # -*- coding: utf8 -*- import codecs from BeautifulSoup import BeautifulSoup, NavigableString, UnicodeDammit import urllib2,sys import time try: import timeoutsocket # http://www.timo-tasi.org/python/timeoutsocket.py timeoutsocket.setDefaultSocketTimeout(10) except ImportError: pass h=u'\u3000\u3000\u4fe1\u606f\u901a\u4fe1\u6280\u672f' address=urllib2.urlopen('http://stock.eastmoney.com/news/1408,20101022101395594.html').read() soup=BeautifulSoup(address) p=soup.findAll('p') t=p[2].string[:10] with the following output: print t ¡¡¡¡ÐÅϢͨ print