From: Keith G Hicks on 6 Nov 2009 13:35 Thanks for the info Branco but G�ran was right. It's not UTF-8. I can see why you'd think that based on the header that was in the original file but that's in there incorrectly which is why I need to change it. "Branco Medeiros" <branco.medeiros(a)gmail.com> wrote in message news:3581e5f8-4b5c-4672-9acb-773007cdb952(a)f16g2000yqm.googlegroups.com... G�ran Andersson wrote: <snip< > Specify the encoding when you read the lines, that way you will read the > rest of the file correctly: > > Dim fileName As String = Path.Combine(xmlFilesLocation, sArticleToPost) > Dim iso = Encoding.GetEncoding("ISO-8859-1") > Dim lines As String() = System.IO.File.ReadAllLines(fileName, iso) > > lines(0) = "<?xml version=""1.0"" encoding=""ISO-8859-1""?>" > System.IO.File.WriteAllLines(fileName, lines, iso) <snip> I may be wrong, but it seems to me that your code tries to read the file as if it was in ISO-8859-1 ecoding, while the OP's first post states that the files are in UTF-8 and he wants then in ISO-8859-1. He is probably reading garbage atm. If he wants to pursue this approach, then the *reading* encoding should be set to UTF8: <aircode> Dim FileName As String = _ Path.Combine(xmlFilesLocation, sArticleToPost) Dim Lines As String() = _ System.IO.File.ReadAllLines(FileName, Encoding.UTF8) Lines(0) = "<?xml version=""1.0"" encoding=""ISO-8859-1""?>" System.IO.File.WriteAllLines( _ FileName, Lines, Encoding.GetEncoding("ISO-8859-1")) </aircode> HTH. Regards, Branco.
First
|
Prev
|
Pages: 1 2 3 4 Prev: "Form Files" not grouped in my solution explorer? Next: Socket stuck in CLOSE_WAIT |