iPhone how do I programmatically substitute a degree symbol for the letter o in a string? - iphone

I know how to replace text in a string. But that's using keyboard (ASCII) characters. In Objective C, how do I indicate a degree symbol? Also, how do I get the ASCII code for a character?

The degree symbol is Option-Shift-8 => °. I believe you can also do: #"\u00B0".
To get the ASCII code for a character, just get the character into a char and cast the char to an int.

To find characters not on your keyboard, select "Special Characters…" on the Edit menu.
To find ASCII values, look on http://www.asciitable.com/

Option shift 8 also gives a similar character. It's the one I always use and I'm not sure of the difference between the two, except the SO font option 0 has a line under it.
Option+Shift+8 = °
Option+0 = º

Related

How to use FT_Load_Char in Arabic (compatibility characters)

This is a follow-up of this question. I'm interested by different glyphs for the same character, also known as "Unicode Compatibility Characters".
Let's take the following two Arabic "reversed-character" words: كلمة ةملك
First word is:
كلمة
in hex code:
0643 0644 0645 0629
Second word is:
ةملك
in hex code:
0629 0645 0644 0643
If I paste those two words in Microsoft Word using Deja Vu Sans, I get this:
With the following pseudo-code using FreeType2, I get:
FT_Face face;
FT_New_Face(library, "DejaVuSans.ttf", 0, &face);
FT_GlyphSlot slot;
FT_Load_Char(face, each_character, FT_LOAD_RENDER);
slot = face->glyph;
//Use slot->bitmap.buffer
FT_Done_Face(face);
What am I missing? How can I have the right glyphs depending of the context?
My key issue is that I store each "character" (I should say glyph - but for me, character was equivalent to glyph) in a table so it's going to be complicated. I'm limited in speed, not in space. Can I have two different unicode characters for the same logical character?
libraqm is a solution to get the glyth for each character depending of its position in the sentence. But I'm still interested to get the character corresponding to the glyth (I know it's not a 1-to-1 relation). For instance, there are 4 characters for the 4 glyths of the letter Kaf as stated in the comment above.

Check Half width Katakana character in COBOL

I'm working on RedHat6 and using COBOL. I wanna check every single digit of variable, if it's half width --> CONTINUE, Else --> DISPLAY ERROR. Basicly I list all half width characters in WHEN Clause of EVALUATE statement. Like this:
PERFORM VARYING WK-IX FROM 1 BY 1 UNTIL WK-IX > WK-LENGTH
EVALUATE WK-FORMAT-CHK-VALUE(WK-IX:1)
WHEN 'A'
WHEN 'B'
WHEN 'C'
CONTINUE
WHEN OTHER
DISPLAY 'ERROR'
END-EVALUATE
END-PERFORM.
Everything is OK but when compile I have problem with half width katakana character. It said: "The ending quotation mark of the literal is missing. The characters at the end of Area B are assumed to be a literal" with all line check these character:
ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ヲ ン
Although I sure there isn't any line of code miss the ending quotation mark. Like this:
WHEN 'ツ'
WHEN 'テ'
WHEN 'ト'
But these character is OK and I don't know why:
ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ
Anyone can help me? Please!
Sorry for my bad English!
Because the Katakana character set is considered a multi-byte character set (as mentioned by Bill Woodger), you will need to ensure that the NSYMBOL and DBCS compile options are enabled. After that, you should be able to define the literals like this:
EVALUATE WK-FORMAT-CHK-VALUE(WK-IX:1)
WHEN N'ツ'
WHEN N'テ'
WHEN N'ト'
do something
WHEN OTHER
do something else
END-EVALUATE
the N will tell the program that this is a national character and as such is multi-byte.
Your input to the evaluate clause will also need to be defined as a PIC N rather than a PIC X. A PIC X field will not recognise double byte characters.

What's the ASCII character code for '—'?

I am working on decoding text. I am trying to find the character code for the — character, not to be mistaken for -, in ASCII. I have tried unsuccessfully. Does anybody know how to convert it?
Quotation from wiki (Em dash)
When an actual em dash is unavailable—as in the ASCII character set—a double ("--") or triple hyphen-minus ("---") is used. In Unicode, the em dash is U+2014 (decimal 8212).
Em dash character is not a part of ASCII character set.
— is known as an Em Dash. It's character code is \u2014. It is not an ASCII character, so you cannot decode it with the ASCII character set because it is not in the ASCII character table. You would probably want to use UTF8 instead.
Windows
For Windows on a keyboard with a Numeric keypad:
Use Alt+0150 (en dash), Alt+0151 (em dash), or Alt+8722 (minus sign) using the numeric keypad.
This character does not exist in ASCII, but only in Unicode, usually encoded by UTF-8.
In UTF-8, characters are encoded by 2- or 3-byte sequences (or occasionally longer), where none of the two or three bytes is a valid ASCII code, where all of them are outside the ASCII range of 0 through 127.
One suspects that the foregoing only partly answers your question, but if so then this is probably because your question is, inadvertently, only partly asked. For further details, you can extend your question with more specifics.
The character — is not part of the ASCII set.
But if you are looking to convert it to some other format (like U+hex), you can use this online tool. Put your character into the first green box and click "Convert" (above the box)
further below you'll find a number of different codes, including U+hex:
U+2014
Feel free to edit this answer if the link breaks or leave a comment so I can find a replacement.
Alt + 0151 seems to do the trick—perhaps it doesn't work on all keyboards.
alt-196 - while holding down the 'Alt' key, type 196 on the numeric keypad, then release the 'Alt' key

Print Unicode Characters in 8086

As you know, the print function in 8086, puts character in 8bits ( db ) and shows it in screen. Now, i want to print the Unicode character in 8086emu environment not ASCII. So, my challenge is how to use Unicode character in my program ? Does 8086 support Unicode characters?
Thanks in advance :)
If you mean printing in text mode, via interrupt 10h: you can't, as you only have a character map with just 256 characters available. You can redefine how these characters look like (load your custom font), but that still gives you only 256 characters. So you would need to identify the ones you need and then first somehow "render" the ones you need into the character table and for printing you would need to map the Unicode glyph to you character table indexes.
See also my answer to a similar question for more details.

How to get stroke count of Chinese character?

How to get stroke count of Chinese character?
Example>
一 => 1
十 => 2
日 => 4
Short answer: You can't without a hardcoded map of characters to stroke counts. And then, you'll have to assume the user is using a particular Chinese variant (e.g. traditional.)
Unicode (the basic character set used by NSString) doesn't distinguish between traditional, simplified, Japanese-specific, Korean-specific, etc. hanzi. Unicode does not encode stroke information directly. Rather, it distinguishes between characters (not their graphical representations) and a character may have different stroke counts depending on language and font used. So while the character 十 may universally have two strokes, other characters will vary.
The example Wikipedia gives is the character for "grass", U+8279, which has four strokes in traditional Chinese, but 3 in every other variant.
You can use "ssc install cnstroke" STATA command for the said purpose.
Thanks, math.
First, call
NSInteger section = [[UILocalizedIndexedCollation currentCollation] sectionForObject:yourObject collationStringSelector:#selector(objectsProperty)];
then check index of section in following array
[UILocalizedIndexedCollation currentCollation].sectionTitles
Remember to add
Localized resources can be mixed = YES
in info.plist