Thursday, March 27, 2008

VB.net - reading extended ascii text file - StreamReader changes extended ascii to question marks

Ran into an issue today reading a text file in Visual Basic .net. The file had extended ascii characters (special "curly quotes" to be exact) that were being read in as question marks because they were outside of the normal ascii character set. The solution was to set the text encoding to "default" in the StreamReader constructor, which is apparently the setting used for "Windows ANSI" text encoding:

Dim fileReader As System.IO.StreamReader
Dim filePath as String

filePath = "C:\path\to\file.txt"
fileReader = New System.IO.StreamReader(filePath, System.Text.Encoding.Default)

While fileReader.Peek <> -1

curLine = fileReader.ReadLine
' do something with curLine
End While

fileReader.close()

Wednesday, March 19, 2008

A simple Javascript slideshow

I built this tool for a site I was working on, then realized it might be helpful to other people, so I thought I'd share it. The code below allows for a simple fading javascript slideshow that can be easily made by dynamic by your PHP or ASP (etc...) scripts. Included in the zip file is a working example slideshow along with the .js files you'll need to use it on your own site.

You can view the slideshow in action at this link:

http://www.phpfuse.net/JS_Slideshow/example/example.html

You can download the code and example at the link below. Enjoy!

http://www.phpfuse.net/JS_Slideshow/Simple_Javascript_Slideshow.zip