I want to learn how to place and overbar on text string.
I tried the back slash on a text string and it did not work, does this trick only work on pin names?
Related
There seems to be a problem with the String library that apple uses.
Here's my Localizable.strings
"error_failed_to_retrieve_certificate" = "เกิิดผิดพลาดในการกู้คะแนน";
Here's how I set it to any view
anyView.text = return NSLocalizedString("error_failed_to_retrieve_certificate", comment: "")
But somehow the string that is being displayed gets warped, when it gets displayed, (the second character becomes different.
Here's what it looks like too when I search it using the Project Search.
But on the Strings it looks different (notice the third character)
Here's one image that is side by side
Note that I don't know any Thai.
It seems like that your string has an extra ิ (U+0E34 THAI CHARACTER SARA I) in it. The character before that, กิ, is already two code points combined - ก (U+0E01 THAI CHARACTER KO KAI) and ิ, so the extra ิ got displayed alone. I would say it's an Xcode bug.
I've removed the extra character here:
เกิดผิดพลาดในการกู้คะแนน
Copy and paste that and it should be fine.
You need to check if you have unique key "error_failed_to_retrieve_certificate". this key value is unique.
I have a Swift application for iOS where inherit from XMLParser to parse an XML file. In one section I grab an attribute which may contain \n characters. These strings are used as button titles later.
Sample XML:
<button title="TitleLine1\nTitleLine2"/>
And in my didStartElement() function:
var buttonTitle : String = attributeDict["title"]
This grabs the title just as I would expect, however later when I create the button and apply the title, the newline character is simply printed right in line on the button instead of making the button title two lines.
I expect the button to look like this:
TitleLine1
TitleLine2
But it ends up being:
TitleLine1\nTitleLine2
If I forget the XML parsing altogether and simply hard code the button title with a literal string like this, the newline works:
button.setTitle("TitleLine1\nTitleLine2", for: .normal)
However setting it with my variable results in the newline being printed in line:
button.setTitle(buttonTitle, for: .normal)
Is there some different way the XMLParser handles strings? I notice the same behavior if I simply do a print() with the XML parsed string vs a literal string.
A \n in a Swift string literal is converted to an actual newline character during compilation.
The character \ followed by the character n in some piece of text obtained at runtime has no special meaning of any kind.
You have a few choices. When you parse the XML, you can process all strings and replace occurrences of the character sequence \n with an actual newline character:
let str = someXMLValue.replacingOccurrences(of: "\\n", with: "\n")
Another option is to change your XML structure to use an element for the title instead of an attribute. Then you can put a real newline in the title:
<button>
<title>TitleLine1
TitleLine2</title>
</button>
Then your Swift code doesn't need to do anything special to deal with newlines.
I have added some text in DB containing curly quotes . So need to change the character encoding which changes curly quotes and similar different style symbols into normal quotes and symbols.
Sample as shown below :
Issue as shown below: Hi This is “text“
Required as per this: Hi This is "text"
I have some strings stored in a plist dictionary, the values of which i would like to display in a textview.
the strings are stored with \n for new lines, however when i pull out the string, it shows \n characters as literals instead of converting them to new lines
Here is the code to pull out the value
self.directions.text = [NSString stringWithFormat:#"%#",[self.exerciseDetail objectForKey:DIRECTIONS_KEY]];
How can i fix it?
Stored strings: some text \n some more text \n some more text
The problem here is that the plist file is storing the string with "\" and "n" characters, rather than a single newline character. The best fix (in my opinion) would be to fix the plist file to have the correct characters. If you are using the plist editor built into Xcode, then hitting the Enter key moves you to the next field. To get around this, hold the Option key while typing Enter and a newline will be inserted.
I am getting problem while parsing xml files that contains some special characters like single quote,double quote (', "")etc.I am using NSXMLParser's parser:foundCharacters:method to collect characters in my code.
<synctext type = "word" >They raced to the park Arthur pointed to a sign "Whats that say" he asked Zoo said DW Easy as pie</synctext>
When i parse and save the text from above tag of my xml file,the resultant string is appearing,in GDB, as
"\n\t\tThey raced to the park Arthur pointed to a sign \"Whats that say\" he asked Zoo said DW Easy as pie";
Observe there are 2 issues:
1)Unwanted characters at the beginning of the string.
2)The double quotes around Whats that say.
Can any one please help me how to get rid of these unwanted characters and how to read special characters properly.
NSString*string =[string stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:#" \n\t"]];
The parser is apparently returning exactly what's in the string. That is, the XML was coded with the starting tag on one line, a newline, two tabs, and the start of the string. And quotes in the string are obviously there in the original (and it's not clear in at least this example why you'd want to delete them).
But if you want these characters gone then you need to post-process the string. You can use Rams' statement to eliminate the newline and tabs, and stringByReplacingOccurrencesOfString:WithString: to zap the quotes.
(Note that some XML parsers can be instructed to return strings like this with the leading/trailing stuff stripped, but I'm not sure about this one. The quotes will always be there, though.)