Winforms problem with codepage "?" char instead of apostrophe ' - vb.net

In .NET 3.5, I have a Winform with a combobox in it. The datya comes from a DB2 mainframe DB. The problem is that we have a character that is not the real apostrophe. Pasted from Word I'd guess. But in our combobox, it is not diplayed correctly. It shows a question mark "?" instead.
Any idea on how could I get it to display the character as it is ?

First you should check if the character is intact in the database, or if the problem is that the code page doesn't support the character.
If the code page used in the database doesn't support the character, it has been replaced with a question mark, and the data is lost. The best you could do in that case is to try to figure out which question marks are the result of data loss, and which are supposed to be question marks, and try to recreate the data.
If the character is intact in the database, you should just need to make sure that the font used to display the text supports unicode.
Note: The character used is probably a typographic apostrophe like unicode character U+2019.

Related

MS Access VBA and report issue with unicode UTF-8 / UTF-16

I have an issue with MS Access reports. I have a code in VBA where string type sentences are added with some specific local letters (e.g. ąčęėįšų). These are printed to report. However, report changes these letters to unknown and not understandable symbols. This started to happen after changing laptop and seems that unicode has changed from UTF-8 to UTF-16. Is there a simple solution how to solve it in report?
Found solution myself. If you want to add some symbol, use VBA function "ChrW(xxx)" where instead "xxx" add code for symbol. This solved the case.

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.

How do I keep the apostrophes when importing csv to sqlite

I am using an SQL database in an android app and have encountered a problem with apostrophes.
My database is a quotes database which I have in MS Excel 2007, then saved in .csv format. I then imported this into the sql table I have for the app. However the quotes with an apostrophe are not displaying correctly in the database (and therefore the app). Each apostrophe is replaced with a character that is invisible. I know it is there because of the character count and the fact that in the word "aren't" for example which looks like "arent" it take 3 clicks of the right arrow to get from the left side of the n to the right side of the t. If I manually add an apostrophe to the sql table it converts back to this invisible character when the database is saved. In the android app this invisible character shows up as a hollow rectangle.
I am sure the issue does not lie in my app's displaying of the quote because I have passed in a String to the same code and it displays apostrophes perfectly fine.
Is there a way to fix this issue, possibly by changing the character set or something like that? or does SQL not support apostrophes?
Since a single quote and apostrophe are the same character you have to do something in sql to tell the database when to treat it as part of a string or when to use it to surround a string. In every RDBMS of which I am aware, if you want the character to be part of a string, you "quote the quote", ie you change ' to '' when talking to your database.
That seems to be only part of your problem. The other part is that your android app displays this character as a rectangle instead or an apostrophe. That's got nothing to do with sql. That is a function of the android application.
I found an alternative solution to the problem.
At runtime of the app I'm replacing the invisible character with an apostrophe and the final string is then how the quote should look.
String quote = (get the quote from the SQL table)
char[] tempQuoteCharArr = new char[quote.length()];
tempQuoteCharArr = quote.toCharArray();
for(int i = 0; i < quote.length(); i++){
if(tempQuoteCharArr[i] == ''){
tempQuoteCharArr[i] = '\'';
}
}
quote = String.valueOf(tempQuoteCharArr);
The invisible character is between the single quotes in the if statement.

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.