This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
UILabels and Unicode
Is there a way to use math symbols in UILabels and UITextField just like the html ÷ × −, ° etc.?
Just drag the symbols from Mac OS X' Character Viewer to Xcode. Than it should look like
label.text = #"÷ × −, ° ";
No need to deal with codes or html-entities.
If you have html-entities in your text, this category might be helpful: GTMNSString+HTML
You can't use the HTML encodings, but you can embed the actual symbols directly into your code or your XIB files as Xcode treats Objective-C source files as Unicode / UTF-8.
To convert a string myHTMLString which has the encoded symbols, use
NSString* convertedString = [myHTMLString stringByDecodingHTMLEntities];
and use this NSString* category: (Just include "NSString+HTML.m" in your source) https://github.com/mwaterfall/MWFeedParser/blob/master/Classes/NSString+HTML.m
Related
I comment some code in my project and don't want these to be built into my app's binary.
Does Xcode build comments code into its binary?
//Obj-C
//- (void)functionName {
//
//}
//Swift
//func functionName() {
//
//}
For Swift: From The Basics in the “The Swift Programming Language” (emphasis mine):
Use comments to include nonexecutable text in your code, as a note or reminder to yourself. Comments are ignored by the Swift compiler when your code is compiled.
For Objective-C: Objective-C is an extension of C, and the C 99 standard specifies in “5.1.1.2 Translation phases” (emphasis added):
3 The source file is decomposed into preprocessing tokens6) and sequences of white-space characters (including comments). A source file shall not end in a partial preprocessing token or in a partial comment. Each comment is replaced by one space character. New-line characters are retained. Whether each nonempty sequence of white-space characters other than new-line is retained or replaced by one space character is implementation-defined.
and in “6.4.9 Comments”:
1 Except within a character constant, a string literal, or a comment, the characters /* introduce a comment. The contents of such a comment are examined only to identify multibyte characters and to find the characters */ that terminate it.
2 Except within a character constant, a string literal, or a comment, the characters // introduce a comment that includes all multibyte characters up to, but not including, the next new-line character. The contents of such a comment are examined only to identify multibyte characters and to find the terminating new-line character.
Short answer: No.
Long answer:
Every single SDK has a compiler that compiles code into machine language (aka, hexadecimal codes for each of the commands). So, all compilers will ignore comments 100%, so that it can compile codes faster.
In terms of Apple's app, it is bundled such way that in it is packed with all the assets (images, sounds, plist, that are able to be viewed by anybody with the .app file. This is the case where hackers were able to create exactly same app but with slightly different graphics/sounds and resubmit as their own.
Together with those assets, is the BINARY UNIX EXECUTABLE file, which if you open in a notepad, you will see gibberish (machine code cant be read by notepad). Example below is one of my app:
This question already has answers here:
How to represent Unicode character in VB.Net String literal?
(7 answers)
Is it possible to get a copyright symbol in C# Console application?
(5 answers)
Closed 6 years ago.
How do i output special characters to the console in visual basic. because simply putting console.writeline("Copyright symbol") outputs a C instead of the symbol. how can i fix this.
You can use the ChrW() function with the Unicode decimal value of the symbol you want to print, for the Copyright symbol it is 169.
console.writeline(ChrW(169))
You can find the Unicode decimal values for other symbols on this website.
The real copyright symbol is a unicode character. Use \u00A9 instead of C to print it out correctly.
I'm displaying a multiline NSAttributedString on a UILabel, I have a problem with the line breaking. When wrapping a word that ends with a plus sign ('+'), the UILabel breaks the line before the '+' sign.
I tried every lineBreakMode available but no matter what I do, if the last word of the line ends with '+', it'll break before it.
For example, using the text "My name is Fred and C++ is my language"
The UILabel will render in two lines like this:
"My name is Fred and C"
"++ is my language"
In this article on Apple's documentation (link) says:
The text system determines word boundaries in a language-specific manner according to Unicode Standard Annex #29 with additional customization for locale as described in that document. On OS X, Cocoa presents APIs related to word boundaries, such as the NSAttributedString methods doubleClickAtIndex: and nextWordFromIndex:forward:, but you cannot modify the way the word-boundary algorithms themselves work.
Any ideas?
Put a Unicode U+2060 WORD JOINER between each of the visible characters in C++. You can use \u2060 in a string literal, or you can use the Unicode Hex Input keyboard to type it as ⌥2060.
I'm using the following to define an NSString containing the Tab character:
#define TAB #"\t"
I'm writing a longer NSString to a file using writeToFile:atomically:encoding:error, using encoding: NSUTF8StringEncoding. This longer NSString contains TAB characters.
When I open the resulting file in TextEdit, I see a character that looks like a Japanese glyph in the place of the TAB character. Here is a screen shot of a line that is intended to have two tab characters, but which has these odd characters instead:
odd characters http://www.market-research-services.com/starpowermedia/for_distribution/tab-char-anomaly.png
What is the correct way to #define an NSString that will contain a TAB character to be written to a file of NSUTF8StringEncoding?
Thanks in advance to all for any info.
I need to display Vietnamese in my APP. But now, i cannot show the words in correct format. For example, the word "&#code" i cannot convert it to Vietnamese, it just display "&#code;".
Does anyone can help me how to handle the word in unicode ?
Thanks a lot!
Tisa
Just write the unicode string inside #"..." without quoting. Strictly speaking, that's non-portable, but as long as you use it for just for Objective-C, it should be OK. It should work on a modern XCode toolchain.
In general, you need to understand that &#... is a way to quote unicode character in HTML, not in a C-string. In C, if you want to be most portable, you need to use \x escapes. Some newer compilers accept \u... and \U... for unicodes.