When I paste a string into Xcode I always get an error and have to re-type it - objective-c

This happens every time I paste a line of code containing a string into Xcode. for example when I pasted this into Xcode:
simonLabel.text = #"Good Job!";
I received an error saying that there was an "unexpeceted '#' in program"
If I delete everything and retype exactly the way I pasted it I do not get an error.

There are too many problems that can appear there:
" can be a different character that you expect
(space) can be a different character that you expect
invisible characters. Something you won't see in the editor at all but they got there with the copy-paste.
All these problems can happen because
You copy it from a website with different encoding (or from a really badly writter website)
You copy it from a smart editor (e.g. MS Word, Open Office) which replaces some of the characters to match locale (e.g. quotation marks) or replaces/add spaces based on grammar and word wrapping (e.g non-breaking space).

Related

Testing for non-ascii characters copied from webpages

So, I'm finding lots of things about removing non-ascii characters, but not really adding them.
Basically, I have a text field that a user can type in, and then that string gets processed, stored, and presented under certain contexts. I expect the user to sometimes just copy and paste text from other webpages, and I want to make sure that nothing the user enters in that field will break anything. (I know this is a potential problem because a user coping and pasting a ' that was not actually an ascii ' already broke things once)
This is NOT about removing non-ascii characters! I want a good list/file of possible problem characters I can copy and paste to verify that they get processed correctly. Or at the very least, a good way to find these potential copy paste 'impostor' characters.
Thank you Tom Blodget. After shifting through and minimizing text, the following is a list of all UTF-8 characters that can be copied and pasted. (here is UTF-16 and UFT-32 lists. I don't have time to copy these lists to a text file. If those links are broken, use Google for UFT-16 table and Google for UTF-32 table)
!"#$%&'()*+,-./0123456789:;<=>?#ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĂ㥹ĆćČčĎďĐđĘęĚěĹ弾ŁłŃńŇňŐőŒœŔŕŘřŚśŞşŠšŢţŤťŮůŰűŸŹźŻżŽžƒˆˇ˘˙˛˜˝–—‘’‚“”„†‡•…‰‹›€™

How can I disable automatic string detection in VS2015?

I'm using VB.NET, and my code contains a lot of strings that very often have double quotes inside of them. My problem is that as I'm fixing the string to escape double quotes (replacing every '"' with '""' inside of the string) it messes with the proceeding code, temporarily assuming everything is a string (since the double quotes don't match up) and completely messing up the formatting of other strings. It assumes that the start of a following string is the end of the current string which causes the actual string to be interpreted and formatted as code, which I have to go back and fix (since it adds spaces and other formatting characters that shouldn't actually be there).
Is there any way to disable this behavior? I didn't have the same problem in VS2013. I've been looking under Tools > Options > Text Editor > Basic, but I couldn't find anything relevant.
Additional Information: I can just modify the strings in a separate text document to escape all of the double-quotes (which is what I've resorted to for now), but in VS2013 I could easily just copy/paste the strings directly into my code without it messing up proceeding strings by temporarily interpreting them as code due to the uneven count of double-quotes.
This behavior is especially problematic when manually adding double-quotes within strings, because if you don't escape them quickly enough (or make a brief typo when doing so), you get the same issue.
You might notice that for other languages, such as C++, writing a string on one line (even with an uneven number of double-quotes) does not affect proceeding lines. Having this same behavior for VB would be great, assuming that there's some setting to enable it.
Yes its an inconvenience.
What I usually do is put some non-used character (e.g. some unused symbol on keyboard, or Alt+{some number}) instead of double quotes. When I'm done building my string whatever way I want, I just finalize it with either bringing up the Find and Replace box and replace that character with two double-quotes. Or just put a REPLACE statement immediately following it, replacing that character with Chr(34).
Instead use Chr(34), or if you end up repeating strings at all, store them as a resource.

VBA: How to Reference Large Unicode Characters like Paperclip?

I know that similar question has been asked many times before but all I found was about characters up to 2-byte long. I need:
MyString = "📎"
The PAPERCLIP is (U+1F4CE) (http://www.fileformat.info/info/unicode/char/1f4ce/index.htm) and the
ChrW(128206) 'throws an error
HOW to reference the unicode chars longer than 2 bytes?
This is a job that your text editor ought to take care of. My memory of the VBA editor is hazy, I don't recollect any way to force the text encoding of the source code file and trying it quickly with the VBA editor in Excel 2013 looks very unpromising. It turns the utf-16 surrogate pair into two question marks.
Switching to another editor could work, Notepad works fine with the Encoding setting in the Save As dialog forced to "Unicode" for example. But that is hardship, with high odds that the string gets mangled again when you continue editing with the VBA editor. The workaround is to specify the surrogate pair explicitly. Try:
MyString = ChrW(&HD83D) & ChrW(&HDCCE)
Google "utf16 surrogate pair calculator" if you need to do this more than once.

iphone sdk , apostrophe showing up as question mark

The quotation marks (apostrophe to be more specific) single and double are displaying as question mark on my text view.
The problem come up when I try to copy and paste some thing from a webpage and save it.
This problem does not happen when I type the sentence.
How can I replace a apostrophe with a regular single quote?
When you copy from a webpage you are not copying a plain old apostrophe. You are copying a fancy one that looks very similar but is not. Since the text view only displays plain text it cannot understand your fancy apostrophe.
When you copy from a webpage you will have to manually delete and retype the apostrophes.
You have to do a string replace probably with unicode characters. The following may be the characters that you want to replace:
Char Unicode HTML
“ 8220 “
‘ 8216 ‘
” 8221 ”
’ 8217 ’

Displaying a Downward Triangle in VB.NET ▼ (U+25BC)

Hey, I'm trying to figure out how to display the ▼ character properly in a .NET winform application.
I am creating a custom control, and for the button, I want this character to appear. I am able to set the text to this character, but it appears as a blank square.
Any ideas on what I need to do to make this character appear properly on my forms?
I am using Arial font, which is compatible with this symbol.
EDIT: It is currently being set as follows:
btnCalendarToggle.Text = "▼" 'Yes, it appears exactly like this in my code
More information on the character can be found here:
http://www.fileformat.info/info/unicode/char/25bc/index.htm
EDIT2: I tried adding some other Unicode characters, and got the following message:
"Some Unicode Characters in this file
cannot be saved in the current
codepage. Do you want to resave this
file as Unicode in order to Maintain
your data?"
After clicking YES on this message, it still didn't work. It appears that the encoding method may be wrong for the file... I don't know what to set it to. Has anyone else tried to display this character in a winform before?
There can often be issues (both with source control systes and diff tools) if you embed more complex unicode characters in source files.
It is often better to do it via an explicit escape sequence and keep the source file in a simpler encoding.
btnCalendarToggle.Text = "\u25BC";
If this works it is likely that the problem is instead the encoding settings for the source file.
Are you certain however that the font in question is Arial (try debugging and checking) since regardless of the above mentioned issues so long as the encoding is set to a legitimate Unicode one (and Visual Studio will convert the file for you if you embed such a character in it) this should have worked.
Can you post the code you are currently using ?
You can print out characters using the chr(int) function if you know the character code.
Dim i As Integer
For i = 0 To 255
txtTest.Text = txtTest.Text & Chr(i) & " -- " & i.ToString() & Environment.NewLine
Next i
Try that and see if your character prints out.