i have an xls with text in different languages, which include also german, greek, and so on.
I have to copy these texts to a html file.
The resulting text is not shown as expected, with special characters, like umlauts or greek characters.
For example: i have a cell with the word "öko"
Using something like:(to read)
test = Cells("36", "D").Value
and(to write):
fso.WriteLine ("<title>" & StrConv(test, vbUnicode) & "</title>")
what i see as title in the html file is ??k?o?.
Do i have to install or configure something in my system?
Thanks in advance
I think you missed a parameter in your OpenTextFile call. If the fourth parameter is -1, then it is Unicode.
Have a look at https://msdn.microsoft.com/de-de/library/314cz14s(v=vs.84).aspx
Related
I have to type Spanish character (ñ) in VBE but I get n instead of ñ. I'm using polish version of Excel. Do you know how I can change that?
If you're typing the letter into a string then you can use the chr function. For example:
mystring = "jalepe" & chr(164) & "o"
It lengthens what should be simple strings, but it gets the work done.
If you need ñ for a function name or something similar, then hod's comment to your question should help you.
I have a problem with Turkish characters in my simple VBA code. Whenever I write some text in my module in Turkish characters (e.g. 'ş, ə, ç, ğ, ö, ü, ı"), they change to unknown letters.
I want to change "Eight" to "Səkkiz","Five", "Beş","Three" "Üç" etc.
May be you should change Font in the text editor
Try: Tools > Options at the 2nd tab choose Font Courier New (Turkish)
The VB editor doesn't support Unicode. Assuming that wherever you're displaying these characters does, you can do something like this:
Const UpsideDownE As Long = &H1DD
Sub Example()
' This would set the currently selected text in PowerPoint to ə
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange = ChrW(UpsideDownE)
End Sub
Of course, choose names for the constants that make sense to you ... whatever you'd normally call the ə character.
I have a pdf file. Then i select and copy "K([2.2.2]crypt)]5[Co2Sn17".
But in clipboard there is "KACHTUNGTRENUNG([2.2.2]crypt)]5ACHTUNGTRENUNG[Co2Sn17".
Any ideas what is "ACHTUNGTRENUNG"? Is it a kind of protection?
There likely are a few extra (invisible) characters in the file. When you copy the text, the application you use to copy translates the characters in the PDF file into something that can be stored on the clipboard. Most likely that happens by translating every character into the unicode string stored in the PDF file for that character in the used font.
For most normal characters the Unicode string should be the same as the character you visually see; here you probably have invisible spaces in the PDF file that are called "achtungtrenung" in the font.
If you have the PDF file available somewhere, I'll be happy to take a look and verify this is indeed what is happening.
It's extra characters between lines.
You can try the PDF Copy Paste software, and see if your desired portion can be converted to text of your preferences.
I know you can put Unicode character codes in a VB.Net string like this:
str = Chr(&H0030) & "More text"
I would like to know how I can put the char code right into the string literal so I can use Unicode symbols from the designer view.
Is this even possible?
Use the ChrW() function to return Unicode characters.
Dim strW As String
strW = ChrW(&H25B2) & "More text"
The C# language supports this with escapes:
var str = "\u0030More text";
But that isn't available in VB.NET. Beware that you almost certainly don't want to use Chr(), that is meant for legacy code that works with the default code page. You'll want ChrW() and pass the Unicode codepoint.
Your specific example is not a problem, &H0030 is the code for "0" so you can simply put it directly in the string literal.
Dim str As String = "0MoreText"
You can use the Charmap.exe utility to copy and paste glyphs that don't have an easy ASCII code.
Replace Chr with Convert.ToChar:
str = Convert.ToChar(&H0030) & "More text"
To display an Unicode character, you can use following statement
ChrW(n) where n is the number representing de Unicode character.
Convert.ToChar(n)
type directly character in editor using Alt + N key combination
paste/copy Unicode character directly in editor
Char.ConvertFromUtf32(n)
XML String using &#x....; syntax
Example to assign ♥ character :
s = ChrW(&H2665)
s = Convert.ToChar(&H2665)
s = "♥" 'in typing Alt+2665
s = "♥" 'using paste/copy of ♥ from another location
s = Char.ConvertFromUtf32(&H2665)
s = <text>I ♥ you</text>
BUT when Unicode Character is greater than 0xFFFF (C syntax is more readable 😉), only method 4, 5 and 6 are working !
ChrW() function indicates an error at build
Convert.ToChar() function crashes at runtime
Alt+N is refused because it accepts only 4 digits
Example
lblCharacter.Text = "This solution works 😉"
Debug.Print (Char.ConvertFromUtf32(&H1F600))
s = <text>diable: 😈</text>
PS: smiley pasted (0x1F600) directly in Visual Studio code editor or Notepad++ have lost background color ! Explanation: the smiley pasted in this answer is filled by orange color but in Visual Studio editor or Notepad++, this color has disappeared !
To use String literals in Visual Studio Editor, you must use method 3 or 4 !
In Form (Design mode)
In Properties (see Text property)
I was hoping you could use XML literals and XML escapes but it doesn't work. I don't think XML literals allow you to use &#NN;. Although it is a way of including quotes " inside strings.
'Does not compile :('
Dim myString = _
<q>This string would contain an escaped character if it actually compiled.</q>.Value
I use the Character Map utility (charmap.exe). Run and select the characters you want in the control's font, such as ©Missico™, copy then paste into the Text property in the property grid. You will have to change the font because the default font for a form is "Microsoft Sans Serif" which is not a Unicode font. I do not think you can use this method for non-printable characters.
Depending on your needs, you can also use Localization, which creates resource files for each language. Again, you would use charmap.exe to select and copy the characters needed and paste them into the resource file. You probably can use non-printable characters, such as tabs, newline, and so on, since this is just a text file (Unicode).
No, it's not possible since VB strings don't support escape sequences. Simply use ChrW, which is a few characters more to type, but also a bit cleaner.
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.