Posts

Showing posts from July, 2009

Druid: The Database Manager

Image
The druid is a tools that allows users to create databases in a graphical way. The user can add tables, fields, folders to group tables and can modify most of the database options that follow the SQL-92 standard. In addition to sql options, the user can document each table and each field with HTML information. Once the database is created, the druid can generate: HTML documentation: for all tables, with browsing facilities PDF documentation: for all tables Java classes: (one class for each table) that contain tables' constants (such as fields size) plus java code added by the user A data dictionary that contains all tables and fields present in the database SQL script which contains all table definitions that can be piped to the DBMS http://druid.sourceforge.net/

How to create unicode files using VBA?

Image
Using the Scripting Runtime library you can create a unicode text file and write to it like: Sub test() 'set reference to Microsoft Scripting Runtime lib Dim strFile As String, strRange1 As String, strRange2 As String Dim fso As FileSystemObject Dim txtStrm As TextStream strFile = "Y:\Work\MyFile.htm" 'amend as appropriate strRange1 = Range("A1").Value strRange2 = Range("A2").Value Set fso = New FileSystemObject Set txtStrm = fso.CreateTextFile(strFile, Overwrite:=True, Unicode:=True) With txtStrm .WriteLine strRange1 .WriteLine strRange2 .Close End With End Sub You must set a reference within the VBE via Tools>References to the Microsoft Scripting Runtime lib.

Reading a unicode Excel file in PHP

Image
It's easy to save an Excel file as CSV and read it in PHP with the fgetcsv function but this may not work so well if the file contains non-English characters. Excel uses a non-standard character encoding for csv files. You can save an Excel file as 'unicode' text however there are several unicode systems - Windows uses UTF-16, and PHP uses UTF-8. To open the 'unicode text' file in PHP you have to convert it, in addition you may want to be able to open UTF-8 files that may be created by other systems. PHP has an encoding detection function - but it can't detect UTF-16. I've solved the problem with the following function which detects from several encodings, adds an appropriate filter, and returns a filehandle which reads as UTF-8. function fopen_utf8 ( $filename ){ $encoding = '' ; $handle = fopen ( $filename , 'r' ); $bom = fread ( $handle , 2 ); // fclose($handle); rewind ( $handle ); if( $bom === chr ( 0xff ). chr ( 0xfe