yoy.be "Why-o-Why"

2007 ...

januari (10) februari (11) maart (14) april (10) mei (13) juni (10) juli (6) augustus (10) september (9) oktober (9) november (10) december (8)

UTF encoding over your IInternetProtocol implementation (encoding, charset? none of such!)

2007-07-05 12:12  i1237  coding  [permalink]

Aah, doesn't it feel good you finally found what you've been searching for such a long time. A few hours, days, weeks...

I noticed IE was showing the pages it got over my [[Asynchronous Pluggable Protocol Handler]] in the default windows encoding. Though I was taking care that everything was coming out nicely in correct UTF-8.

I tried putting "text/html; charset=utf-8" in as mime-type but that doesn't work.

I was looking into IInternetProtocolInfo to see if IE calls that one to get more info on the encoding, it doesn't...

So it was time to google, and it's always good to see you're not alone:
http://groups.google.com/groups?hl=nl&ie=ISO-8859-1&q=iinternetprotocol+encoding&lr=&oe=ISO-8859-1&um=1&sa=N&tab=wg

But still those don't hold the answer also, so the search went on. Until for another project I solved an encoding problem by ensuring the UTF Byte Order Mark is at the beginning of each file. Before that I didn't really know UTF-8 had a BOM also! I had noticed the 'ÿ»¿' characters from time to time when encoding was wrong, but had the luxury of being able to ignore those.

So, to get the 'auto-detect' encoding in IE right, start sending by sending the Byte Order Mark of UTF-8 or UTF-16 first!

http://en.wikipedia.org/wiki/Byte_Order_Mark


twitter reddit linkedin facebook

Photoshop rules the world

2007-07-11 21:16  i1240  film  [permalink]

http://www.canneslionslive.com/film/win_1_1.htm

Nog geen zo'n domme zet van Dove om het over de andere boeg te gooien.


twitter reddit linkedin facebook

Google maps: breedte-/lengtegraad van een punt

2007-07-11 21:23  i1241  weblog  [permalink]

En ik maar zoeken hoe je gemakkelijk de lengte-/breedtegraad van een bepaald punt zou kunnen opzoeken!
Eerst was ik aan het prutsen met [[Google Earth]], maar die is niet zo precies, en de foto's van België waren (toen toch) niet zo scherp.
Maar nu heb ik dus ontdekt dat je gewoon gan rechterklikken op http://maps.google.be/, dan kies je 'routebeschrijving naar hier' zonder een vertrekpunt te kiezen, en dan zegt em dat hij geen route kan leggen naar... je gekozen lengte-/breedregraad.

Tis te zeggen, precies de cijfers die je op deze site nodig hebt om na "googlemap:" te zetten, bijvoorbeeld:

googlemap:51.074949,3.777623,15


twitter reddit linkedin facebook

forms posted multipart/form-data only have first character as name

2007-07-23 23:10  i1246  coding internet  [permalink]

wierd: there might still be something wrong with my UTF-8 or UTF-16 encoding, but still... this doesn't look right:

Content-Disposition: form-data; name="u"; filename="C"

twitter reddit linkedin facebook

ExecuteReader requires the command to have a transaction...

2007-07-26 10:22  i1248  dotnet  [permalink]

I had a real nice data-application, that bundled some changes in XML with the schema and a diffgram using datasets, but as an added check I wanted to have the whole thing run in a transaction.

I thought this would do the trick:

SqlConnection

db = new SqlConnection(myConnectionString);
db.Open();

SqlTransaction

tr = db.BeginTransaction();
try
{
...
using (SqlDataAdapter da = new SqlDataAdapter(myQuery, db))
{
SqlCommandBuilder cb = new SqlCommandBuilder(da);
...
}
...
tr.Commit();
}
catch
{
tr.Rollback();
throw;
}
db.Close();

No such luck! The command builder failed in doing its magic:

ExecuteReader requires the command to have a transaction when the connection assigned to the command is in a pending local transaction.  The Transaction property of the command has not been initialized.

So I had to search my way through anything I could find, using any [[Google]]s and [[Reflector]]s of this world I came across, just to discover that it's all fixed by putting the transaction on the DataAdapter's SelectCommand! The CommandBuilder copies that one nicely to all the other commands it confabulates.

SqlConnection

db = new SqlConnection(myConnectionString);
db.Open();

SqlTransaction

tr = db.BeginTransaction();
try
{
...
using (SqlDataAdapter da = new SqlDataAdapter(myQuery, db))
{
da.SelectCommand.Transaction = tr;
SqlCommandBuilder cb = new SqlCommandBuilder(da);
...
}
...
tr.Commit();
}
catch
{
tr.Rollback();
throw;
}
db.Close();

twitter reddit linkedin facebook

Delphi: what's wrong with FileExists

2007-07-27 08:33  i1250  delphi  [permalink]

When you write a Delphi application (Win32, I guess this is not an issue when you use .Net) that handles a lot of files that come from devices and storage media, you may have come across a little problem with FileExists.

When the file's last modified date is set to an invalid date, or got corrupted, you'll notice it won't show in the list when viewing the directory in Windows. The file itself exists and may be perfectly valid. Still Delphi's FileExists may result false on the file.

FileExists internally uses FileAge to check whether the file is there. FileAge gives an integer value that reflects the last modified date of a file, which is really convenient for checking if a file got changed by last time you checked, but also fails (returns -1) on files that have the last modified date missing or corrupt.

One way to circomvent is to define a new FileExists function that directly checks with the file-system of the file exists.

uses Windows;

function FileExists2(const FileName: string): boolean;
var
Handle: THandle;
FindData: TWin32FindData;
begin
Handle := FindFirstFile(PChar(FileName), FindData);
if Handle <> INVALID_HANDLE_VALUE then
begin
Windows.FindClose(Handle);
if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY)=0 then
Result:=true
else
Result:=false;
end
else Result:=false;
end;

twitter reddit linkedin facebook