home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 9,657 of 10,840   
   Gary to All   
   converting UNICODE text files to ANSI   
   18 Aug 05 11:28:25   
   
   From: levenson_g@comcast.net   
      
   Hi,   
      
   I have to convert some UNICODE text files to ANSI in VB 6. I thought this   
   would be pretty straight forward, but the code blows up. I open the file as   
   binary and then convert the whole mess to ASCII using StrConv:   
      
      
   Dim sFile As String   
   Dim fsoStream As TextStream   
   Dim sFileBytes() as Byte   
   '   
   '   
   Open strFile For Binary Access Read As #fh   
   fileLength = LOF(fh)   
      
   '   
   ' create an output file to write the converted data   
   '   
      
   Set fsoStream = fso.OpenTextFile(tempFileName, ForWriting)   
   sFileBytes = StrConv(InputB(fileLength, #fh), vbFromUnicode)   
   sFile = sFileBytes   
   Debug.Print sFile   
   fsoStream.Write sFile   
      
   it blows up with an exception trying to write the stream to the file. Any   
   suggestions would be greatly appreciated.   
      
   Thanks.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca