Tag Archives: convert

Remove all accents in NSString

// convert to a data object, using a lossy conversion to ASCII
NSData *asciiEncoded = [yourOriginalString dataUsingEncoding:NSASCIIStringEncoding

// take the data object and recreate a string using the lossy conversion
NSString *other = [[NSString alloc] initWithData:asciiEncoded
// relinquish ownership
[other autorelease];

Via Stackoverflow.com

Converting View to Bitmap without displaying it

Here is the Android code for converting a View object to Bitmap without displaying it. This can be useful for displaying complex views in a Gallery widget.

Bitmap bmp = Bitmap.createBitmap(Utils.getPixelForDp(width, this), Utils.getPixelForDp(height, this), Bitmap.Config.ARGB_8888);
View v = getLayoutInflater().inflate(layoutid, null);
v.measure(MeasureSpec.makeMeasureSpec(bmp.getWidth(), MeasureSpec.EXACTLY), 
MeasureSpec.makeMeasureSpec(bmp.getHeight(), MeasureSpec.EXACTLY));
v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight()); 
v.draw(new Canvas(bmp));

Best source: Stackoverflow.com