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.
Related
There are times when you need to input modified variables with diacritical marks, or superscripts.
Seems like declare_index_properties allows doing it at the stage of display print.
But it is neither simple, nor very useful in formulas.
is there a simple way of adding hats, umlauts, and ', "strokes on top of a symbol, making it distinguishable from the symbol without such mark both to interpreter and to human eye?
Maxima doesn't have a notion of declaring a symbol to have diacritical marks or other combining marks on it. However, Maxima allows Unicode characters in symbol names if the underlying Lisp implementation allows Unicode; almost all of them allow Unicode. GCL is the only Lisp implementation, so far as I know, which doesn't handle Unicode correctly.
WxMaxima appears to allow Unicode characters to be input. At least, it worked that way when I tried some examples. Command-line Maxima allows Unicode if the terminal it is running in allows Unicode.
I think any Unicode character should be OK in a string. For symbols, any character which passes ALPHA-CHAR-P (a build-in Lisp function) can be part of a symbol name. Also, any character which is declared to be alphabetic (via declare("x", alphabetic) where x is the character in question) can be part of a symbol name.
I think wxMaxima has some capability to allow the user to select characters with diacritical marks from a menu; I haven't tried it. When I want to use Unicode characters, I end up just pasting them from a web page or something. I have used https://www.w3.org/2001/06/utf-8-test/UTF-8-demo.html as a source of characters in the past.
Is anyone aware of a smalltalk library for converting Unicode to ascii?
I'm hoping that it will be somewhat intelligent, i.e. remove diacritical
marks. Non-ascii characters would either be removed or replace with
something like an underscore. E.g.:
"ěščřžýáíé ❤"
would be converted to:
"escrzyaie _"
or:
"escrzyaie "
Thanks,
Alistair
As was clarified in the comments, my goal was to be able to convert
filenames containing non-ascii / non-printable characters into something
that would still be meaningful but only contain ascii characters.
Using the Diacritics library kindly pointed out by Peter I ended up
writing a small class that does the conversion. If you're interested,
it is at:
https://github.com/akgrant43/AkgMiscellaneousUtilities/tree/master/mc/AKG-AsciiFilename.package
Thanks for all the assistance!
I'm trying to make a console-based program that makes use of ANSI escape codes with GNU Smalltalk. I can't seem to figure out how to go about printing a string object formatted with ANSI escape codes. I've tried the following.
'\x1b[31mHi' displayNl
This prints the entire string, including the escape code, without any formatting. I would have expected this to print "Hi" in red (and then everything else in the console after that, as I didn't reset the color.)
After googling a bit, I was able to find a couple issues on mailing lists where people were trying to produce things like newlines using "\n". Most of the answers were using the Transcript object's cr method, but I didn't find anything about colors in the textCollector class.
It looks like it shouldn't be all that hard to create my own module in C to achieve this functionality, but I'd like to know if there's a better way first.
I'm aware of the ncurses bindings, but I'm not sure that'd be practical for just making certain pieces of text in the program colored. So, is there a standard way of outputting colored text to the terminal in GNU Smalltalk using ANSI escape sequences?
Ended up getting an answer on the GNU Smalltalk mailing list. Looks like you can use an interpolation operator to achieve this.
For example ('%1[31mHi' % #($<16r1B>)) displayNl. would change the color to red, and ('%1[34mHi' % #($<16r1B>)) displayNl. would change the color to blue.
Basically, the % operator looks for a sequences that look like "%(number)" and replaces them with the objects in the array to the right of the operator. In our case, the array has one item, which is the ascii escape character in hexadecimal. So the "%1" in "%1[31mHi' is being replaced with the escape character, and then printed.
(This answer was stolen almost verbatim from Paolo on the GNU Smalltalk mailing list.)
How could i convert a Greek string, to Unicode with VB.NET, without knowing the source encoding?
Without knowing you can't do something very reliable.
But if you know for sure it will be Greek, then you can try the supported Greek code pages:
windows-737 = OEM - Greek 437G
windows-869 = OEM - Modern Greek
windows-875 = IBM EBCDIC - Modern Greek
windows-1253 = Windows - Greek
windows-10006 = MAC - Greek I
windows-20423 = IBM EBCDIC - Greek
windows-28597 = ISO 8859-7 Greek
The most likely one is 1253 (not 1250 as above).
But you can try all of them, one at the time, then check if the resulting characters are in the Greek (and maybe Latin, if you want to accept that).
For validation you can use RegExp with \p (http://msdn.microsoft.com/en-us/library/az24scfc.aspx#character_classes) and using the desired Unicode blocks (http://msdn.microsoft.com/en-us/library/20bw873z.aspx#SupportedNamedBlocks).
You can try [\p{IsBasicLatin}\p{IsGreek}]* (and maybe add IsGreekExtended, although you will not get that from any of the listed code pages).
If you get something else (let's say Cyrillic) you know you got the wrong code page.
Sorry, but without knowing the code page all you do is guess. And there is only so much you can do to improve that guess.
i have some truetype fonts and a programm takes these fonts so that a user can select a font he like to put some symbols around. The programm save these information (which font name und character code) in a file. (I dont have the source of this programm)
Now i have to reed these file into another programm (vb.net) and get the character from the character code. And here comes the problem.
If i'll try chr(144) i'll get an empty char back ... but in the font which the user has selected befor, the character, which display a symbol, exists with the character ç.
Have i to load the font on runtime or what i have to?
I have tried already CharW(144) but with the same result: I'll get an empty char but i need to get the ç
Kind regards
Nico
According to the Extended Latin-1 code chart, ç is U+00E8 (232 in decimal) so I suggest you try ChrW(232).
The value returned by Chr depends on the current thread's default encoding (and I seem to remember it's possible to provoke some odd results) - I would try to avoid it if possible. If you know the encoding you need to use, then use it explicitly with Encoding.GetString etc. Otherwise, stick to Unicode values wherever possible.