Hi there,
I have a very large text file (some 400,000 lines of text) that I'm loading into memory with VBA, I then use VBA to analyse and sort the data, before putting it into Excel. I use the folling code to load the text file into memory...
This takes a few seconds to run and has been working fine, up until some special characters have appeared in the text file, and so when I load in the file they get messed up. So for example "Sion" becomes "SiA'n" (missing some accents there). It turns out that the program that creates the text file can only output in UTF-8 encoding, and seemingly VBA only really deals with ASCII, hence the text getting screwed up. I have tried the following code to allow me to load in UTF-8, but it is painfully slow to the extent I cannot use it for my application. So my question is, does anyone have any other options I can try that allows me to load in UTF-8 encoded text, but that's also fast?![]()
iFile = Freefile Open sFile For Input As #iFile LoadTextFile = Input$(LOF(iFile), iFile)
![]()
Dim objStream As Object Dim strData As String Set objStream = CreateObject("ADODB.Stream") objStream.Charset = "utf-8" objStream.Open objStream.LoadFromFile (sFile) LoadTextFile = objStream.ReadText()
Chris
Bookmarks