I want to replace the unicode: å with Norwegian character å but the following code is not helping:
[unq1 stringByReplacingOccurrencesOfString:#"å" withString:#"å" ];
It is working perfectly on my side, may be the problem is you have not save the result of this stringByReplacingOccurrencesOfString method. So try like this
unq1 = [unq1 stringByReplacingOccurrencesOfString:#"å" withString:#"å"];
Related
I need to add some french translation into iOS Application. But I don know how to use single qute char in the Localizable.strings file.
For example text :
"Invalid username or password."="Nom d'utilisateur ou mot de passe incorrect.";
Causes an error. I've tried adding backslashes, but it havn't worked as well.
Using Special Characters in String Resources Just as in C, some
characters must be prefixed with a backslash before you can include
them in the string. These characters include double quotation marks,
the backslash character itself, and special control characters such as
linefeed (\n) and carriage returns (\r).
From:
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/LoadingResources/Strings/Strings.html
Did you try escaping it with a backslash?
"\'"
As a last resort you could use direct U codes:
You can include arbitrary Unicode characters in a value string by
specifying \U followed immediately by up to four hexadecimal digits.
The four digits denote the entry for the desired Unicode character;
for example, the space character is represented by hexadecimal 20 and
thus would be \U0020 when specified as a Unicode character. This
option is useful if a string must include Unicode characters that for
some reason cannot be typed. If you use this option, you must also
pass the -u option to genstrings in order for the hexadecimal digits
to be interpreted correctly in the resulting strings file. The
genstrings tool assumes your strings are low-ASCII by default and only
interprets backslash sequences if the -u option is specified.
The apostrophe should be \U0027
Its not replacing comma, in case of Arabic language.
NSString *strAfterReplacingComma = #"٢٠٠٫٠٠";//100.00
NSString *strAfterReplacing = [strAfterReplacingComma stringByReplacingOccurrencesOfString:#"," withString:#"."];
NSLog(#"%#", strAfterReplacing);
Can anyone please help me in solving this?
The comma in your Arabic text (٫) has a unicode number U+002C. It is the arabic decimal separator. Not a comma. The english Comma(,) has a unicode number U+066B. Hence the replace fails.
Use this ٫ instead of , in you stringByReplacingOccurrencesOfString.
I have a string which contains Swedish characters and want to convert it to basic English.
name = "LänödmåtnÖng ÅjädårbÄn"
These characters should be converted as follows:
Å use A
å use a
Ä use A
ä use a
Ö use O
ö use o
Is there a simple way to do it? If I try:
ascii_to_string = name.unpack("U*").map{|s|s.chr}.join
It returns L\xE4n\xF6dm\xE5tn\xD6ng \xC5j\xE4d\xE5rb\xC4n as ASCII, but I want to convert it to English.
Using OP's conversion table as input for the tr method:
#encoding: utf-8
name = "LänödmåtnÖng ÅjädårbÄn"
p name.tr("ÅåÄäÖö", "AaAaOo") #=> "LanodmatnOng AjadarbAn"
Try this:
string.mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/n,'').downcase.to_s
As found in this post.
You already got decent answer, however there is a way that is easier to remember (no magical regular expressions):
name.parameterize
It changes whitespaces to dashes, so you need to handle it somehow, for example by processing each word separately:
name.split.map { |s| s.parameterize }.join ' '
I'm using the symbol font Symbolicons instead of images in a new project. However, it seems that any code over 4 characters can't be set using NSString.
Example:
self.saveDealButton.titleLabel.font = [UIFont fontWithName:#"SS Symbolicons" size:31.0f];
[self.saveDealButton setTitle:#"\u1F4E5" forState:UIControlStateNormal];
Will not work, however:
self.shareButton.titleLabel.font = [UIFont fontWithName:#"SS Symbolicons" size:31.0f];
[self.shareButton setTitle:#"\uF601" forState:UIControlStateNormal];
Works fine. How can I get NSString to recognize the extra bit?
For those characters in the Supplementary Multilingual Plane, as in your example, use the uppercase U in the escape string and followed by eight hex code. So it should be written as \U0001F4E5.
In iOS unicode characters belong to a 16bit representation \u , with n between 0000 and ffff in hexadecimal notation.
In your example \uF601 represents one character and you could add another character by adding another sequence \uF601\uF602 etc.
For me it seems that you misunderstood the escape syntax?
I'm trying to process a German word list and can't figure out what encoding the file is in. The 'file' unix command says the file is "Non-ISO extended-ASCII text". Most of the words are in ascii, but here are the exceptions:
ANDR\x82
ATTACH\x82
C\x82ZANNE
CH\x83TEAU
CONF\x82RENCIER
FABERG\x82
L\x82VI-STRAUSS
RH\x93NETAL
P\xF2ANGE
Any hints would be great. Thanks!
EDIT: To be clear, the hex codes above are C hex string literals so replace \xXX with the literal hex value XX.
It looks like CP437 or CP852, assuming the \x82 sequences encode single characters, and are not literally four characters. Well, at least everything else does, but the last line is a bit of a puzzle.