I assume the troll noticed that Indians often call people 'dear', and decided to up the ante...
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
I would like to know the best/proper way of handling foreign or special characters between XML, disk file, and XML Soap Reader (UTF-8).
Given that a VB6 program request a XML Soap Web Service. It gets the response and write it to a file using VB6 Open ... as output, print #nn, s....
A VB.NET program then reads this file via XMLTextReader but it fails due to a
'Invalid character in the given encoding'. The character is a 'ü' in München. I am sure there will be more. MSIE cannot read the file either.
So what is the best way to get or write these characters. Hopefully I don't have to check each character.
I guess my suggestion would be on the fields you know have special charaters use the base64encode before you put the item into the xml file. Then on the other end you will decode that field when you put it out. I just showed you my example of doing this with a cdata node which is more complicated then you need to do. Encoding the field will take care of the characters that are causing you problems.
So I have to check every character for all the special characters??? The first article does an encoding for every byte for email, etc. Is that the right article?
It seems strange that if I get a XML block in from Web Services that I would have to encode it to be viewed by an XML program like either MSIE or my XMLTestReader program.
I think that I just do not understand what is going on.
I am assuming that if the XML block comes in as UTF-8 that the ü is OK as is. So does it change when I write it to disk. I can still see a ü in the file but MSIE doesn't like it.
Ok, I see your problem. Your default encoding for when you write the file to disk is most likely not UTF-8. That perhaps is the direction you need to be going. I was encoding my stuff because I was stuffing xml inside of a cdata node of a soap message which is also xml. If I didn't encode it, it just would work.
I actually remember running into a similar problem. If you look at your code with whatever stream you are using to write out the xml file, one of the overloaded options will include passing in the encoding. I would suggest that you pass that in as UTF-8 and it very may well fix your problem.
The error occurs even when MSIE tries to open the file indicating that either the file was written bad or the data came in bad. The .net program fails when 'reading' the file in XMLTextReader. It is already to late by then.
If you have the correct encoding it seems like this should work. I think you need to try to write out whatever encoding that is support in vb6 that supports these characters and then read it in with that same encoding in vb.net
After I write it I usually let MSIE try to read it. If MSIE can't then my VB.NET will probably fail as well.
I can write is as Unicode. But MSIE will not be able to read it unless I change
encoding="utf-8"? to utf-16.
But this doesn't seem to be right. I would think that there should be an easier way just to write an XML block to disk without all the fuss.
Question: When the accented character is read from Web Services in VB6 the data looks and displays fine (the ü looks like a u with 2 dots). It is also written do disk and it still looks fine with Notepad. Then why is it that MSIE stops with an Invalid Character on ü. Is the enocoding in utf-8 different from ASCII.
UTF-8 is different the ascii. Are you sure it is the ü that is causing your xml file to fail? Perhaps you are having other issues? If you want to send the bad xml file to me, you can sent it to email@example.com
Yes, I am sure. If I change the character to a normal u with notepad it works fine. I cannot send the file since it has customer info in it. But I removed all the data and created a small file with just 1 tag.
<?xml version="1.0" encoding="utf-8"?>
And MSIE fail on it. I will send the file via email also.
So this is saying that when I read the data from web services that the ü is now ASCII? Or when it is written to disk it is change to ASCII?
The BitArray class doesn't support conversions to other types (EDIT: I completely forgot about CopyTo!!).
If you're only using 8 bits, you're much better off just using a Byte and doing the bit manipulation yourself. It's easy to write your own methods to automate some of this, like setting or resetting a bit.
A quick little whip up:
Public Shared Function SetBit(ByVal value As Byte, ByVal position As Integer) As Byte
If position < 1 Or position > 8 Then
Throw New ArgumentOutOfRangeException("Position must be between 1 and 8.")
Dim mask As Byte = CByte(2 ^ (position - 1))
If Not value And mask Then
value = value Or mask
-- modified at 13:06 Wednesday 2nd May, 2007
Dave Kreskowiak Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
i made an application like notepad and i want when i click on any text file then my application should start so i select my application in open with and i coded in form1_load of my application
Dim newLine As String = ""
Dim cmdLine As String
open.InitialDirectory = System.Environment.SpecialFolder.Desktop
If InStr(System.Environment.CommandLine, ".txt") Then
cmdLine = System.Environment.CommandLine
Dim charInLine As String
Dim quoteCharStop As Integer = 0
Dim placeInString As Integer = cmdLine.Length - 1
While quoteCharStop < 2 And placeInString > 0
charInLine = cmdLine.Substring(placeInString, 1)
If charInLine = Chr(34) Then
quoteCharStop = quoteCharStop + 1
newLine = charInLine & newLine
placeInString = placeInString - 1
If File.Exists(newLine) Then
Dim o As StreamReader = File.OpenText(newLine)
Text1.Text = o.ReadToEnd()
Text1.SelectionStart = 0
Text1.SelectionLength = 0
savechk = False
its working but when i open large file the application appear blank(i.e. rich text box blank)
someone know the solution??
i also want to code a button as when i click on then it should change open with program to mine application
Last Visit: 31-Dec-99 18:00 Last Update: 11-Apr-21 6:38