Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Convert unicode string into ascii



Maybe I'm missing something from your example, previous postings, and my ISP's web mail client, but it appears your desired output doesn't seem to match in character count to your original text.  Nevertheless, if all you want is to turn low-ASCII (values less than 0x20) and high-ASCII (values greater than 0x7F) into period characters, you'd find better performance and flexibility for your particular needs by simply writing a function that takes an unsigned 8-bit integer (e.g., in a loop, 0x01, 0x08, 0x0B, ..., 0x13) and returns the desired character.  In that function, do your test for low-ASCII and high-ASCII, returning the period character in those cases, and the supplied character in all other cases.  Since this code is pretty trivial, you could even inline it rather than code it into a separate function, but I don't know if you need to call it in more than one place in your code.

>yes, it is for a small hex reader.
>I need to read some old c64 file (.prg) then
>visualize the hex and the ascii
>so when I translate this:
>
>01 08 0B 08 01 00 9E 32 30 36 31 00 00 00 A9 93
>20 D2 FF A9 08 85 FC 8D 6B 10 A9 38 8D DC 17 A9
>30 8D DB 17 A9 37 85 01 A9 13
>
>I get this:
>
>î2061	ì¢PêàU(6ìà3!pj0É1	7Ö	 2U	É 
>¢2êRPêÇP⁄	ÖP	ÖQP)U0B• ÇRÉe$ÄÄê
>00Q!)P)PE)•ê5ríÖ2íPê⁄É4BR Ñ  
>B#x†1îX10$êRêX
>
>so,not nice looking string :)
>
>What I want to see after parsing is:
>
>..........2061......k..8.....0....7....
>
>etc etc_______________________________________________
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.