I have an NSMutableArray miniResults which contains the following NSStrings.
List 1, Some strings have German umlauts.
After putting miniResults into NSString solution with this:
solution = [NSString stringWithFormat:#"%#",miniResults];
solution contains converted strings what I don´t want.
List 2, All umlauts converted!
I don´t see why this happens.
What am I doing wrong?
Any ideas?
The compiler seems to escape them to unicode. Shouldn't be a problem anyfurther. I've got no sources for this, but it looks like that.
One possible fast solution would be substituting them. Make "Ae" from "Ä", etc.
Related
I am trying to use Excel::Writer::XLSX. Most things already successfully, but I struggle to get a formula into a cell.
use utf8;
is set
I am trying to set the formula into the cell with the following statement:
$av_obj_excel_worksheet_DATA->write_formula( 'a3', '=_xlfn._xlws.FILTER(gw_col_gwuPMBo,(MONTH(gw_col_DATUM)=1)*(gw_col_gwuPMBo<>0),"_empty")' );
I have the extracted the .xlsx-file (since it is a simple zip-file) and had a look at the relevant xml of the spreadsheet.
The result is:
_xlfn._xlws.FILTER(gw_col_gwuPMBo,(MONTH(gw_col_DATUM)=1)*(gw_col_gwuPMBo<>0),"_empty")
but the result should be, since I created an .xlsx-file manually and had again a look at the relevant xml-file of the relevant spreadsheet:
_xlfn._xlws.FILTER(gw_col_gwuPMBo,(MONTH(gw_col_DATUM)=2)*(gw_col_gwuPMBo<>0),"_empty")
I seems to me some unicode problem.
Unicode is difficult to understand and - I regret - I don't realy do!
Can someone help me what to do to get the correct form of the formula into the .xlsx file (or related .xml-file of the relevant spreadsheet?
Thanks
I already experimented with encode and decode and now found the solution:
$av_tmp_STRING = '=_xlfn._xlws.FILTER(gw_col_gwuPMBo,(MONTH(gw_col_DATUM)=1)*(gw_col_gwuPMBo<>0),"_empty")';
$av_tmp_STRING = decode( 'UTF-8', $av_tmp_STRING );
$av_obj_excel_worksheet_DATA->write_formula( 'a3', $av_tmp_STRING );
the hurdle was that I did not see the result durging debugging the script. But the correct string was written to the .xlsx-file.
Sometimes, by thinking, searching and trying it comes to a positive result.
I currently have a string as follows which I received through an API call:
\n\nIt\U2019s a great place to discover Berlin and a comfortable place
to come home to.
And I want to convert it into something like this which is more readable:
It's a great place to discover Berlin and a comfortable place to come
home to.
I've taken a look at this post, but that's manually writing down every conversion, and there may be more of these unicode scalar characters introduced.
What I understand is \u{2019} is unicode scalar, but the format for this is \U2019 and I'm quite confused. Are there any built in methods to do this conversion?
This answer suggests using the NSString method stringByFoldingWithOptions.
The Swift String class has a concept called a "view" which lets you operate on the string under different encodings. It's pretty neat, and there are some views that might help you.
If you're dealing with strings in Swift, read this excellent post by Mike Ash. He discusses the idea of what a string really is with great detail and has some helpful hints for Swift 2.
Assuming you are already splitting the string and can get the offending format separately:
func convertFormat(stringOrig: String) -> Character {
let subString = String(stringOrig.characters.split("U").map({$0})[1])
let scalarValue = Int(subString)
let scalar = UnicodeScalar(scalarValue!)
return Character(scalar)
}
This will convert the String "\U2019" to the Character represented by "\u{2019}".
How would I go about reading in an input that looks like "01/12/1997" to 3 seperate integers that are 01, 12, and 1997?
If using GNAT, you can use GNAT.String_Split, followed by the 'Value attribute conversion.
And just in case your question was an intermediate step on the way to parsing dates, you should take a look at GNAT.Calendar.Time_IO.Value which knows about parsing various dates formats.
I ended up adding 3 more variables, all strings. I then set them as Date(1..2) and Month(4..5) and Year(7..10), then I converted them all to integers and continued my program. Not the best way, but it worked.
I have a UIWebView displaying string containing a locally generated sequence of Korean and Russian words. I.e. there is nothing special in the string, just simple 'body'/'span' tags to format the text.
I need to get selected text, so I use:
NSString *selected = [articleWebView stringByEvaluatingJavaScriptFromString:#"document.getSelection()"];
This returns nothing: NSLog (#"%#", selected); logs out nothing.
What can be a problem here? I haven't found anyone here having similar problem and it's driving me nuts. Please, help.
OK, I've got it. The following works just fine:
NSString *selection = [articleWebView
stringByEvaluatingJavaScriptFromString:#"window.getSelection().toString()"];
Use this, not that.
Running Coldfusion 8, I am trying to clean text input before saving to a database that will take things like the MS equivalent of ' " - and accented letters, and converting them.
I have tried replace, REReplace, and various UDFs found on the internet. None seem to work. In fact, I tried this:
<cfscript>
function cleanString(string) {
var newString = string;
newString = replace("'", "'", ALL);
return newString;
}
</cfscript>
The single quote to be replaced above is a MS Word style single quote. Coldfusion threw an error, the error scope said invalid syntax and the single quote in the error scope was a square. If I change it to the chr() form, and replace with ', I get a blank. If I do chr() to the entity, I get a blank.
I am more than certain I have jumped this hurdle before, and not sure why nothing is working now. Is there a new setting in CF8 vs CF7 regarding character encoding that I am missing?
There is a great script for demoronizing (yes, that's a technical term) text copied from MS word and the like. It can be found at CFLib:
http://cflib.org/index.cfm?event=page.udfbyid&udfid=725
I've used it several times, and been happy with it out-of-the-box (though I have added some additions for specific applications).