NSString containing aphostrophe (') is not set properly to SOAP service - objective-c

I have strange in my view problem. I have UITextField which contains username. When it contains apostrophe (') the service cannot read username properly. I suppose it is connected with Unicode. I try to see what are the codes and I get:
L'TEST - contains code 8217
' - is 39
` - is 96
can anyone explains to me why this happens so I can fix this issue

L'TEST - contains code 8217
That would be L’TEST with U+2019 ‹’› \N{RIGHT SINGLE QUOTATION MARK}. If you look closely, in most fonts this character is displayed with a slight curl. It's not an apostrophe, but misused as one.
can anyone explains to me why this happens
Common causes:
"The Fool" Some mischievous input system silently substituted apostrophe for quotation mark. Word processors and mobile OS on-screen keyboards do that. It's well-meaning, but sometimes produces the wrong result.
"The Clueless" User is ignorant how to correctly type an apostrophe and picked the similar looking quotation mark.
"The Angry" Your UI text field (or something else in the chain originating from the user) forbids entry of apostrophes for some retarded reason. The user absolutely refuses to write something orthographically incorrect and manually substitutes apostrophe for quotation mark in order to work around the defect software.
so I can fix this issue
This is a social problem, not a software problem.

Since a SOAP service is based on XML and single quotes are a delineator in XML, you need to escape your single quotes by replacing "'" with "\'" in all text fields. It's a very common issue.

Related

How to determine Thousands Separator using Format in VBA

I would like to determine the Thousand Separator used while running a VBA Code on a target machine without resolving to calling system built-in functions such as (Separator = Application.ThousandsSeparator).
I am using the following simple code using 'Format':
ThousandSeparator = Mid(Format(1000, "#,#"), 2, 1)
The above seems to work fine, and would like to confirm if this is a safe method of doing it without resorting to system calls.
I would expect the result to be a single char string in the form of , or . or ' or a Space as applicable to the locale on the machine.
Please note that I want to only use a language statement such as Format or similar (no sys calls). Also this relates to Thousands Separator not Decimal Separator. This article Using VBA to detect which decimal sign the computer is using does not help or answer my question. Thanks
Thanks in advance.
The strict answer to whether it is safe to use Format to get the thousands separator is No.
E.g. on Windows, it is possible to enter up to three characters into the Thousands Separator field in the regional settings in the control panel.
Suppose you enter asd and click OK.
If you now call Format(1000, "#,#") it will give you 1a000. That is only the first letter of your thousands separator. You have failed to retrieve it correctly.
Reading the registry:
? CreateObject("WScript.Shell").RegRead("HKCU\Control Panel\International\sThousand")
you get back asd in full.
To be fair, the Excel international properties do not seem to be of much help either. Application.International(xlThousandsSeparator) in this situation will return the separator originally defined in your computer's locale, not the value you've overridden it to.
Having that said, the practical answer is Yes, because it would appear (and if you happen to know for sure, please post an answer here) that there is no culture with multi-char thousand separator (even in China where scary things like 1億2345万6789 or 1億2345萬6789 exist, they happen to be represented with just one UTF-16 character), and you probably are happy to ignore the people who decided to play with their locale settings in that fashion.

Scrapy: how to solve the "empty" item in html due to a foreign language symbol?

One of the scrapy-ed items seems contain no content in HTML. In MySQL database, it does have content including a non-regular - (dash) that is slightly longer. It could be a dash symbol from Chinese input, or something similar. I am copy it below, not sure whether it will keep the original form. The web link is here and this non-regular dash is in the title and the beginning of the description.
**Hospitalist – Chattanooga**
To further prove it, the export CVS file from MySQL convert this weird dash to ?€?. Most likely this weird symbol causes the non-display problem.
I want to either delete this weird symbol or replace it with a , or a regular dash. Where can it be done? During Scrapy? Or in MySQL? Sorry this is not a specific coding question. I need some guidance before figuring out any codes for this problem.
The long dash is called an EM dash fileformat - EM dash
The reason you are seeing it is likely due to the chosen encoding.
Try setting a different encoding or replacing the EM dash with the , sign as you mentioned in your question.
In php you can do so with the following code:
str_replace(chr(151), ',' $input);

Special characters in the URL

I am working on a ASP.NET MVC app.
This app displays a detail information regarding a product.
The product name can have any special chars like single quote, the percentage symbol, the Registered symbol the one with a circle and 'R' inside, the Trademark symbol etc.
Currently all these are replaced with a '-'.
If the name is like this:
Super - Men's 100% Polyester Knit Shirts
It appears like this in the URL:
8080/super---men-s-100-polyester-knit-shirts/maverick
- men-s-100-polyester-knit-shirts
This is done in Js like so:
Name.replace(/([~!##$%^&*()_+=`{}\[\]\|\\:;'"<>,.\/? ])+/g, '-').replace(/^(-)+|(-)+$/g, '');
So the question is, should the name be displayed as-is in the URL?
If yes, some pointers please.
If no, please provide some valid reasons like standards as followed today that will help me put the point across the table.
Regards.
The short answer is not to fiddle with it. It's as good as it gets out of the box.
The Url can only contain a small number of alphanumeric letters. which basically means you can only have 0-9 a-z and - _ . ~.
All other characters need to be encoded. Now that you can have arabic url's too it has gotten a little more complicated.
But assuming your website is indo-european this is it. So you will never be able to have full product names in your url.
And renaming them as something more cool like replacing % with "percent" in the url can bring desaster upon your url's as in some cases the "fake" names may not end up unique and therefore end up with unreliable routing.
look at URI characters on wiki

"Error validating Name:Invalid string." When Adding Customer

I receive this error when adding a QBO Customer with a name that has greater/less than characters ('>', '<'). I've looked through the documentation and can't find a lit of unacceptable characters. How do I know what is and is not acceptable? I just need to know what to look for to sanitize our local data before uploading.
The API is XML-based, right? That means you need to either escape the characters into ">" and "<" respectively, probably with a standard library available in your environment; or filter the 5 characters listed here.

Dealing with whitespace when parsing XML

I have problem with parsing XML.
I parsed data of cities, Amsterdam & Den Bosch.
Amsterdam works fine but Den Bosch does not.
No doubt it is due to space problem.
Den Bosch has a white space.
Should I trim the whitespace in my application or the web service?
Which would be the best to handle the space problem?
EDIT:
The OP and #PeterMurray-Rust seem to agree that the problem is that the third-party app returns URL-escaped strings of the form:
"Den%20Bosch"
%20 is not recognized by XML as anything special and that it will be necessary to replace occurrences by spaces. A typical scripting approach would be
s/%20/ /g
This is likely to be quite a common problem although I'm not clear why content should be URL-encoded.
[OP please comment if I have got this wrong]
From your update I assume that the data is something like:
<city>Den%20Bosch</city>
The string "%20" is three characters which XML does not regard as having any specific meaning. Depending on your language or whether you use XSLT you will need to replace them. In Java and the XOM library I might write
String value = cityNode.getValue().replaceAll("%20", " ");
I can't help with the specifics of Cocoa - I think you'll have to investigate the API to find how to get content values.
I Assume that you are parsing xml at application level and also by white space you mean the trailing white spaces and not the one in between the words "Den" and "Bosch". In anycase, I think you can trim the spaces at web service level, since you can be rest assured that any call coming from any other application using this web service need not have to trim the spaces since web service handles that internally. This would be a one-point change for you.
Don't know much about cocoa and your xml as well. City names, are these inner text of node or tag name. If it is in tag name or attributes without quotes, it will fail. If it is in inner text, it should work. However, there is CDATA fragment which tells the parser to ignore the contents
This is the code i implemented its working fine..........
if ([appDelegate.cityListArray count]>0) {
aDJInfo=[appDelegate.cityListArray objectAtIndex:indexPath.row];
//http://compliantbox.com/party_temperature/citysearch.php?city=Amsterdam&latitude=52.366125&longitude=4.899171
url=#"http://compliantbox.com/party_temperature/citysearch.php?city=";
NSString *string=[aDJInfo.city_Name stringByReplacingOccurrencesOfString:#" " withString:#"%20"];
url=[url stringByAppendingString:string];
NSLog(#"abbbbbbbbbbb %#",string);
url=[url stringByAppendingString:#"&latitude=52.366125&longitude=4.899171"];
[self parseEventName:[[NSURL alloc]initWithString:url]];
}
}
#All thanks a lot..