Archive for the ‘Software Development’ Category
Posted by jpluimers on 2012/05/24
In the previous post, you saw some XPath to find the ProviderManifestToken attribute in an .edmx file.
Writing XPath queries can be quite consuming, so it is nice of you can test it somewhere on-line.
Out of the on-line XPath testers, these two worked best:
Both of them support namespaces, including these XPath functions: local-name and namespace-uri.
These failed:
If you have more on-line tools that work: please let me know!
Edit (20120524T0930):
Danny Thorpe tweeted an interesting comment:
@jpluimers If you’re compiling XPath support, make note of whether it’s XPATH 1.0 or 2.0. I think .NET only implements XPATH 1.0
Indeed, .NET only supports XPath 1.0, and worse, .NET 4 introduced a couple of issues with XSLT (see XPath and XSLT 2.0 for .NET? – Stack Overflow).
Luckily there are some goot XPath 2.0 libraries for .NET (see XPath 2.0 Libraries for .Net – Stack Overflow).
–jeroen
via: XPath tools on not-another-blog
Like this:
Be the first to like this post.
Posted in Development, Software Development, XML, XML/XSD, XPath | Leave a Comment »
Posted by jpluimers on 2012/05/23
Yes. Dorothy. There are people using the ADO .NET Entity Framework with SQL Server 2000 in parallel of moving towards a more modern Microsoft SQL Server version.
Entity Framework is lovely for developing data-centric applications.
By default, Visual Studio 2010 will target SQL Server 2008 as a database. That is fine, but it is kind of invisible it does: there is no property or dialog where you can change this.
What you have to change in order to have the Entity Framework send SQL Server 2000 compatible queries is to:
- Right click your .edmx file
- Choose “Open with”
- Choose the “XML (text) editor”
- Find the ProviderManifestToken attribute
- Change the value (usually from “2008″) into “2000″
- Save the .edmx file
- Build and run your application
A few caveats:
The ProviderManifestToken is usually at this place:
/edmx:Edmx/edmx:Runtime/edmx:StorageModels/Schema/@ProviderManifestToken
Note this is not a full XPath query to it (as you’d have to add the namespaces see also namespaces in XPath), that would be the one below this post’s signature.
From the ProviderManifestToken documentation:
ProviderManifestToken Schema Attribute
ProviderManifestToken is a required attribute of the Schema element in SSDL. This token is used to load the provider manifest for offline scenarios. For more information about ProviderManifestToken attribute, see Schema Element (SSDL).
SqlClient can be used as a data provider for different versions of SQL Server. These versions have different capabilities. For example, SQL Server 2000 does not support varchar(max) and nvarchar(max) types that were introduced with SQL Server 2005.SqlClient produces and accepts the following provider manifest tokens for different versions of SQL Server.
- “2000″ for SQL Server 2000
- “2005″ for SQL Server 2005
- “2008″ for SQL Server 2008
Note: Starting with Visual Studio 2010, the Entity Data Model Tools do not support SQL Server 2000.
Finally, with SQL Server 2000, be sure to set multipleactiveresultsets=false in your connectionstrings to disable MARS (Multiple Active Result Sets) which SQL Server 2000 does not support.
–jeroen
via: SqlClient for the Entity Framework.
Full XPath query would either have you to add namespaces using an XmlNameSpaceManager instance, or use the full namespace urls like here:
//*[namespace-uri()='http://schemas.microsoft.com/ado/2009/02/edm/ssdl']/@ProviderManifestToken
or more precisely
/*[local-name()='Edmx' and namespace-uri()='http://schemas.microsoft.com/ado/2008/10/edmx']/*[local-name()='Runtime' and namespace-uri()='http://schemas.microsoft.com/ado/2008/10/edmx']/*[local-name()='StorageModels' and namespace-uri()='http://schemas.microsoft.com/ado/2008/10/edmx']/*[local-name()='Schema' and namespace-uri()='http://schemas.microsoft.com/ado/2009/02/edm/ssdl']/@ProviderManifestToken
or on multiple lines:
[sourececode language='text']
/*[local-name()='Edmx' and namespace-uri()='http://schemas.microsoft.com/ado/2008/10/edmx']
/*[local-name()='Runtime' and namespace-uri()='http://schemas.microsoft.com/ado/2008/10/edmx']
/*[local-name()='StorageModels' and namespace-uri()='http://schemas.microsoft.com/ado/2008/10/edmx']
/*[local-name()='Schema' and namespace-uri()='http://schemas.microsoft.com/ado/2009/02/edm/ssdl']
/@ProviderManifestToken
[/sourcecode]
for this .edmx file (hoping that WordPress doesn’t mess with the xml as it usually does).
[sourececode language='xml']
[/sourcecode]
Yup, it did it again; please see this file for the XML.
–EOM–
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Development, EF Entity Framework, Software Development, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012 | Leave a Comment »
Posted by jpluimers on 2012/05/22
Raymond Chen:
what if you don’t want the fault-tolerant heap? For example, during program development, you probably want to disable the fault-tolerant heap for your program: If the program is crashing, then it should crash so you can debug it!
–jeroen
via: How do I disable the fault-tolerant heap? – The Old New Thing – Site Home – MSDN Blogs.
Like this:
Be the first to like this post.
Posted in Software Development, Development | Leave a Comment »
Posted by jpluimers on 2012/05/17
When trying to dissect .NET 1.1 web services from their .asmx and WSDL, you need some tooling.
You’d think the WCF Test Client works, but it only partially generates the calls; it gets the methods OK, but not the parameters.
Importing the .NET WebService in Visual Studio is another option, but not for a “quick play around with the calls”.
For that, Soap UI seems a good option.
If you know better tools, please let me know in the comments.
It works, and when you get it to work it is dead slow (it keeps one core running at 50%).
Getting it to work gives many people this kind of error message: Read the rest of this entry »
Like this:
Be the first to like this post.
Posted in .NET, C#, Development, SOAP/WebServices, Software Development | Leave a Comment »
Posted by jpluimers on 2012/05/16
As a Delphi user, I’m missing the “Reverse Assignment” feature in the Visual Studio version of CodeRush.
Since CodeRush is very extendable (Mark is still explaining to people how the idea for that came from Delphi Packages back in the mid 90s), you can add this one yourself, as the a answer to this DevExpress support issue shows:
Q:
Is there a quick way to reverse the assignment in CodeRush? For example:
FROM:
Field[“test1”] = edTest1.Value;
Field[“test2”] = edTest2.Value;
TO:
edTest1.Value = Field[“test1”];
edTest2.Value = Field[“test2”];
I know Delphi had this capability in its refactoring, does CodeRush for Visual Studio?
Thanks
Daniel Schipper
Read the rest of this entry »
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Development, Software Development, Visual Studio 2005, Visual Studio 2008, Visual Studio 2010, Visual Studio and tools | Leave a Comment »
Posted by jpluimers on 2012/05/15
(Thanks to a “Missed Post” problem on WordPress.com, this one didn’t get posted on the scheduled date. Sorry for any inconvenience)
One of the next steps in the automated build process I’m setting up is increasing AssemblyVersion values after succesful builds.
It is is in a CCnet / TFS2010 / VS2010 environment.
Some links:
–jeroen
via: change assemblyversion during checkin ccnet – Google Search.
Like this:
Be the first to like this post.
Posted in .NET, C#, Continuous Integration, CruiseControl.net, Development, Software Development, Source Code Management, TFS (Team Foundation System) | Leave a Comment »
Posted by jpluimers on 2012/05/15
When in a DTAP environment, you cannot always have complete clean boundaries. Issues in production don’t reproduce in acceptance, you cannot develop in production, etc.
So sometimes you have to simulate or connect to Test or Acceptance Database Servers from a Develop workstation.
There it can get hairy to keep track of which applications connect to which database server.
That’s where the below batch file comes in handy: it scans your systems on connections to common TCP ports used by SQL server, then for each connection give you some process details (or – if you add a commandline parameter – all details that TLINK can get).
The batch file uses the built in tools tasklist, netstat, find and sc (the latter to show information on the local running SQL Services).
It also uses TLIST, which can be a bit awkward to get.
Read the rest of this entry »
Like this:
Be the first to like this post.
Posted in .NET, Batch-Files, Database Development, Development, Scripting, Software Development, SQL, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 7 | Leave a Comment »
Posted by jpluimers on 2012/05/10
To bad that Greg Beechs Blog only has “42 Entries” as those entries (from the start of 2006 till the end of 2009) are well worth reading on various .NET related topics.
–jeroen
via Greg Beechs Blog | Greg Beechs Website.
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, C# 3.0, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2012/05/09
A few notes on TLIST.EXE:
- Lots and lots of articles mention it.
- Not all versions of TLIST.EXE will work on all Windows versions (I found a 40k version 3.51 at a client that clearly hangs on their XP systems, where the version 3.50 works fine but is more limited).
- It is hard to find an actual download.
This is what I downloaded as I prefer ISO files prefer web-installers:
http://download.microsoft.com/download/4/A/2/4A25C7D5-EFBE-4182-B6A9-AE6850409A78/GRMWDK_EN_7600_1.ISO
I got there through these pages (in reverse chronological order)
–jeroen
Like this:
Be the first to like this post.
Posted in Debugging, Development, Power User, Software Development, Windows, Windows 7, Windows Vista, Windows XP | 1 Comment »
Posted by jpluimers on 2012/05/08
Some clients generate their VPN connection settings using the CMAK (Connection Manager Administration Kit). Apart from the cumbersome way to support both x86 and x64 at the same time, they usually add in some kind of time-out feature, and often route the whole 10.0.0.0/8 network over the VPN to just host a couple of dozen machines. Having done most of my VPN connections by hand, and automating them using rasdial to dial these from the commandline, I also found out the hard way that you cannot use rasdial for CMAK generated VPN connections: it will give you the error “This function is not supported on this system.”. The funny thing is: you can disconnect using rasdial. Luckily, the far less well documented rasphonedoes work for dialing. The batch file below uses a few tricks, and you can set the parameters in the top of the batch file.
Have fun with it!
Like this:
Be the first to like this post.
Posted in Development, Power User, Scripting, Software Development, Windows, Windows 7 | Leave a Comment »
Posted by jpluimers on 2012/04/26
Some very interesting tips from game development that apply juts as well to general software development.
On code health:
Now I always try to dig right down to the root cause of a bug, even if a simple, and seemingly safe, patch is available. I want my code to be healthy. If you go to the doctor and tell him “it hurts when I do this,” then you expect him to find out why it hurts, and to fix that.
Though tools like SourceMonitor can help you track your code health, the best tool is between your ears.
–jeroen
via: Dodgy Coder: Coding tricks of game developers.
Like this:
One blogger likes this post.
Posted in .NET, Batch-Files, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Delphi x64, Delphi XE2, Development, JavaScript/ECMAScript, PHP, PowerShell, Scripting, Software Development | 1 Comment »
Posted by jpluimers on 2012/04/24
While transitioning from SQL Server 2000 to 2008, I recently had the “A severe error occurred on the current command. The results, if any, should be discarded.” occurring on SQL Server 2000 in the form as shown at the bottom of this message.
Many of the search results point you into the area of atabase corruption, or in using NVARCAR parameters with SQL Server 2000 or SQL Server 2005 (the app didn’t use NVARCAR, nor did it use large VARCHAR parameters).
The cool thing on the SQL Server Forums – System.Data.SqlClient.SqlException: A severe error occurred on the current command post was that it summed up causes, and asked for more:
Posted - 06/17/2004 : 15:05:20
Rashid writes “Hi: Gurus I am getting these errors when I try to execute my application. According to MS knowledge base (http://support.microsoft.com/default.aspx?scid=kb;en-us;827366) these errors happen due to following resons
- You use a SqlClient class in a Finalize method or in a C# destructor.
- You do not specify an explicit SQLDbType enumeration when you create a SqlParameter object. When you do not specify an explicit SQLDbType, the Microsoft .NET Framework Data Provider for SQL Server (SqlClient) tries to select the correct SQLDbType based on the data that is passed. SqlClient is not successful.
- The size of the parameter that you explicitly specify in the .NET Framework code is more than the maximum size that you can use for the data type in Microsoft SQL Server.
None of these are true in my case. Are there any other reasons that can cause these problems..
There is one more: sending huge SQL Statements to your SQL Server is always a bad idea and gives this error too. Read the rest of this entry »
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Database Development, Development, Software Development, SQL Server, SQL Server 2000, SQL Server 2008 R2 | Leave a Comment »
Posted by jpluimers on 2012/04/18
Everytime I get a warning like
Warning 1 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: 'This method is obsolete, it has been replaced by ConfigurationManager.AppSettings'
it reminds me I should have written a blog post about it, as the solution is a tiny bit more than just replacing System.Configuration.ConfigurationSettings.AppSettings by System.Configuration.ConfigurationManager.AppSettings.
Scott Gate wrote a nice post on his old blog about this (his new blog is awesome, he really should import his old posts into his new blog) that explains how to solve this well, so below is an elaboration on the how of the change, a tiny trick and a short series of steps to resolve this warning.
First of all, the above message means you are touching code that has been written in the .NET 1.x era, and the maintaining people (you! <g>) have been too lazy to solve the warning. That is bad, as your code should compile without warnings, and preferably without hints too. Read the rest of this entry »
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2012/04/17
If you followed my blog, you probably already guessed that I’m assisting a client to prepare for a big SQL Server 2000 to SQL Server 2008 R2 migration. When not, you know now
I’m a fan of commandline, tools, and preconfigured settings. Which means that I’m in the midst of reconfiguring all my shortcuts to SQL Server 2000 tools to SQL Server 2008 equivalents.
When inspecting and changing LNK shortcut files, two tools are important:
- dumplnk: dumps a shortcut lnk file from the commandline
- shurtcut: creates a shortcut lnk file from the commandline
One of tools I many shortcuts for is the ISQLW aka SQL Query Analyzer, which I use far more than the SQL Server Enterprise Manager (more on SSEM in a future post).
Depending on the mode of authentication you use to connect to your SQL Server, there basically are two forms of shortcuts:
- SQL Server Authentication (using SQL Server username and password):
"C:\Program Files\Microsoft SQL Server\80\Tools\Binn\isqlw.exe" /S"servername[\instancename]" /U"username" /P"password"
- Windows Authentication (using the credentials of the currently logged in windows user):
"C:\Program Files\Microsoft SQL Server\80\Tools\Binn\isqlw.exe" /S"servername[\instancename]" /E
The former is less secure (so better to only store those shortcuts in a place that no other users can access).
From the ISQLW.exe syntax documentation:
Syntax
isqlw
[-?] |
[
[-S server_name[\instance_name]]
[-d database]
[-E] [-U user] [-P password]
[{-i input_file} {-o output_file} [-F {U|A|O}]]
[-f file_list]
[-C configuration_file]
[-D scripts_directory]
[-T template_directory]
]
The parameters /S, /U, /P and /E are very similar to the -S, -U, -P and -E ones from SSMS.exe (SQL Server Management Studio) with one distinction: there MUST be a space between each parameter and the value:
- SQL Server Management Studio (using SQL Server username and password):
"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe" -S "servername[instancename]" -U "username" -P "password"
- SQL ServerManagement Studio (using credentials for the currently logged in windows user):
"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe" -S "servername[instancename]" -E
Read the rest of this entry »
Like this:
Be the first to like this post.
Posted in Batch-Files, Database Development, Development, Power User, Scripting, Software Development, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012 | 3 Comments »
Posted by jpluimers on 2012/04/14
I’m experimenting with the Posting categories overview page as a prequel to a proper tag cloud (and a series of posts on how to get there).
Please let me know in the comments which of the below ones you like most:
- Left:
HTML tree with post count per category
- Middle:
HTML tree with font size indicating post count
- Right:
HTML tree with post count per category and font size indicating post count
(For comparison, you need a big screen; the most popular choice will survive on the Posting categories page).
–jeroen
via: Posting categories « The Wiert Corner – irregular stream of Wiert stuff. Read the rest of this entry »
Like this:
One blogger likes this post.
Posted in CSS, Development, HTML, Power User, SocialMedia, Software Development, Usability, User Experience, Web Development, WordPress, WordPress | Leave a Comment »
Posted by jpluimers on 2012/04/12
Coo, I never knew that MS-DOS had STDAUX and STDPRN, I only knew about PRN (I think it mapped to LPT1).
Don’t you love the old new thing
The standard MS-DOS file handles are as follows:
| handle |
name |
meaning |
| 0 |
stdin |
standard input |
| 1 |
stdout |
standard output |
| 2 |
stderr |
standard error |
| 3 |
stdaux |
standard auxiliary (serial port) |
| 4 |
stdprn |
standard printer |
–jeroen
via: The importance of error code backwards compatibility – The Old New Thing – Site Home – MSDN Blogs.
Like this:
Be the first to like this post.
Posted in Development, Power User, Software Development | Leave a Comment »
Posted by jpluimers on 2012/04/11
a BNF grammer for C# v2 has moved from www.devincook.com/GOLDParser/grammars/index.htm to goldparser.org/grammars.
It is mostly complete, and a good learning experience to both BNF and the C# syntax.
ANTLR grammers are available for C# 2, and a partially for C# 4.
–jeroen
via: c# 4.0 – C# grammar in BNF or EBNF Parser generator for F# – Stack Overflow.
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2012/04/10
Lot’s of corporate environments keep killing the productivity of their software developers by running WorkPace. They claim to prevent RSI, but the main thing they do is getting you out of your mental flow.
Workpace (yes, it is written in Delphi) hooks itself into processes by injecting REC300.DLL into it.
That particular DLL prevents Delphi XE2 from installing in several of the systems colleagues tried, and gives you error messages like these:
'' is not a valid integer value
Followed by a bunch of access violations, and Process Monitor indicating issues reading the key HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\REC300.DLL which is part of WorkPace 3.0 (an old 2007 version).
The next problem was Digital Guardian (an old 2010 version) hooking itself into all processes. Uninstalling that is a pain, as it requires a special uninstall key, but luckily the automated update script on the SCCM server’s distribution share contained that in an encrypted form. Uninstalling this solved the problem.
Maybe newer versions of WorkPace and Digital Guardian wouldn’t have interfered with the Delphi XE2 install. If so, that would be another example of technical debt.
WorkPace and Digitual Guardian are most likely there because of government induced regulations in the corporate environment.
I’m feeling a bit like Dilbert now: the corporate environment is interesting, but often they make “getting work done” so much harder than it could be.
–jeroen
Like this:
One blogger likes this post.
Posted in Delphi, Delphi XE2, Development, Opinions, Software Development | Leave a Comment »
Posted by jpluimers on 2012/04/06
If you like .NET and scripting, then PowerShell and the PowerShell Community Extensions is what you should try:
PowerShell – The full power of .NET, WMI and COM all from a command line. PowerShell has a steep learning curve, much like the tango, but oh, my, when you really start dancing…woof. I also use PowerShell Prompt Here. Its built into Windows 7, by the way.
- I also recommend after installing PowerShell that you immediately go get PowerTab to enable amazing “ANSI-art” style command-line tab completion.
- Next, go get the PowerShell Community Extensions to add dozens of useful commands to PowerShell.
- Want a more advanced GUI for PowerShell? Get the free PowerGUI.
Thanks Scott for summarizing
–jeroen
via: Scott Hanselmans 2011 Ultimate Developer and Power Users Tool List for Windows – Scott Hanselman.
Like this:
Be the first to like this post.
Posted in .NET, Development, Power User, PowerShell, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2012/04/05
Finally, Google allows searching for C# and returns meaningful results (previously they returned the same results as searching for C).
They improved a bunch of other special characters as well.
–jeroen
via:
Search quality highlights: 50 changes for March – Inside Search.
Like this:
Be the first to like this post.
Posted in .NET, C#, Development, Google, GoogleSearch, Power User, Software Development | Leave a Comment »
Posted by jpluimers on 2012/04/05

O'Reilly book "Unicode Explained: Internationalize Documents, Programs, and Web Sites"
Withe the growing integration between systems, and the mismatch between those that support Unicode and that do not, I find that a lot of organisations lack basic Unicode knowledge.
So lets put down a few things, that helps as a primer and gets some confusion out of the way.
Please read the article on Unicode by Joel on Software, and the book Unicode Explained. The book is from 1996, and still very valid.
Unicode
Unicode started in the late 80s of last century as a 16-bit character model.
Somehow lots of people still thing Unicode is a 16-bit double-byte character set. It is not. It uses a variable width encoding for storage.
All encodings except the 32-bit ones are variable width. The UTF-16 encoding is a variable width encoding where each code point (not character!, see below why) takes one or more 16-bit words.
This is because – as of Unicode version 2.0 in 1996 – a surrogate character mechanism was introduced to be able to have more than 64k code points.
The architecture of Unicode is completely different than traditional single-byte character sets or double-byte character sets.
In Unicode, there is a distinction between code points (the mapping of the character to an actual IDs), storage/encoding (in Windows now uses UTF-16LE which includes the past used UCS-2) and leaves visual representation (glyphs/renderings) to fonts.
Unicode has over a million code points, logically divided into 17 planes, of which the Basic Multi-lingual Plane has code points that can be encoded into one 16-bit word.
There is no font that can display all Unicode code points. By original aim, the first 256 Unicode code points are identical to the ISO 8859-1 character set (which is Windows-29591, not Windows-1252!) for which most fonts can display most characters.

By now, you probably grasp that Unicode is not an easy thing to get right. And that can be hard, hence people love and hate Unicode at the same time. Maybe I should get the T-Shirt
.
One thing that complexes things, is that Unicode allows for both composite characters and ready made composites. This is one form where different sequences can be equivalent, so there can be Unicode equivalence for which you need some knowledge on Unicode Normalization (be sure to read this StackOverflow question and this article by Michael Kaplan on Unicode Normalization).
There are many Unicode encodings, of which UTF-8 and UTF-16 are the most widely used (and are variable length). UTF-32 is fixed length. All 16-bit and 32-bit encodings can have big-endian and little-endian storage and can use a Byte Order Mark (BOM) to indicate their endinaness. Not all software uses BOMs, and there are BOMs for UTF-8 and other encodings as well (for UTF-8 it is not recommended to include a BOM).
When only parts your development environment supports Unicode strings, you need to be aware of which do and which don’t. For any interface boundary between those, you need to be aware of potential data loss, and need to decide how to cope with that.
For instance, does your database use Unicode or not for character storage? (For Microsoft SQL Server: do you use CHAR/VARCHAR or NCHAR/NVARCHAR; you should aim for NVARCHAR, yes you really should, do not use text, ntext and image). What do you do while transferring Unicode and non-Unicode text to it? Ask the same questions for Web Services, configuration files, binary storage, message queueing and various other interfaces to the outside world.
The Windows API is almost exclusively Unicode (see this StackOverflow question for more details)
Delphi and Unicode
Let’s focus a bit on Delphi now, as that the migration towards Unicode at clients raised a few questions over the last couple of months.
One of the key questions is why there are no conversion tools that help you migrate your existing source code to fully embrace Unicode.
The short answer is: because you can’t automate the detection of intent in your codebase.
The longer answer starts with that there are tools that detect parts of your Delphi source that potentially has problems: the compiler hints, warnings and errors that brings your attention to spots that are fishy, are likely to fail, or are plain wrong.
Delphi uses the standard Windows storage format for Unicode text: UTF-16LE.
Next to that, Delphi supports conversion to and from UTF-8 en UTF-32 (in their various forms endianness).
External storage of text is best done as UTF-8 because it doesn’t have endianness, and because of easier exchange of text in ISO-8859-1.
Marco Cantu wrote a very nice whitepaper about Delphi and Unicode, and I did a Delphi Unicode talk at CodeRage 4 and posted a lot of Delphi Unicode links at StackOverflow.
A few extra notes on Delphi and Unicode:
With Delphi string types, stick to the UnicodeString (default string as of Delphi 2009) and AnsiString (default string until Delphi 2007) as their memory management is done by Delphi. WideString management is done by COM, so only use that when you really need to. Also avoid ShortString.
For any interfaces to the external world, you need to decide which ones to keep to generic string, Char, PChar and which ones to fix to AnsiChar/PAnsiChar/AnsiString(+ accompanying codepage) or fix at UnicodeChar/PUnicodeChar/UnicodeString.
Of course remnants from the past will catch up with you: if you have Technical Debt on the past where characters were bytes, and you abused Char/PChar/array-of-char/etc you need to fix that, and use the Byte/PByte/TByteArray/PByteArray. It can be costly to pay the accrued debt on that.
–jeroen
PS:
Like this:
Be the first to like this post.
Posted in .NET, C#, Delphi, Development, EBCDIC, Encoding, ISO-8859, Software Development, Unicode, UTF-8 | 2 Comments »
Posted by jpluimers on 2012/04/04

Thanks to Randy Glasbergen for the debt image
I love this quote from Jeff Attwood on technical debt in 2009:
periodically pay down your technical debt
and the Computer Weekely article about half a year ago:
Short-term speed may come at the price of long-term delays and cost.
Lately, I find that I need to explain Debt in relation to IT and Software Development more and more often.
We now all know what happens with the financial system when we let debt get out of control.
The same holds for your IT and Software Development.
Debts get introduced by not “playing by the rules”. The quotes are there because you can not always play nicely, and the rules are not always clear or known.
Lets give a few examples of rules that – from experience at clients – are more often than not neglected. The examples are based on Windows, but could just as easily be Mac OS X, Unix, OS/400 or anything else.
- Make sure you use a recent Windows version
I often see companies lagging more than one version behind (i.e. still use Windows XP or SQL Server 2000). That’s too far.
- Don’t run your users with too many privileges (and certainly not as Administrators)
Especially running as Administrator will get you in trouble with User Account Control (UAC) in Windows Vista and up.
- Using directories like C:\TEMP is a no-no.
This should be a no-brainer, but truckloads of in-company software still thinks it can write everywhere.
I know C:\TEMP used to be the Temporary Folder some 20 years ago.
But that was then, and this is now: Use the %TEMP% environment variable or GetTempPath function (even better: the GetTempFileName function or the .NET Path.GetTempFileName function).
More in general for known folders, use CSIDL or KNOWNFOLDERID whenever possible. Your favourite development tool usually has a library functions for that, for instance the .NET System.Environment.GetFolderPath function.
These few were examples ranged from technically very broad to specific. There are more, but these will give you a rough idea how wide the field of debt can be. Even debt outside the realm of Technical Debt can turn out to be really expensive.
Every time you postpone or skip a Windows version, you collect some debt in the hope (often wrongfully called expectation) that you earn more on the money/resource you just didn’t invest and putting that money/resource to use otherwise. The same holds for any other kind of debt.
The main problem with debt is not the total of the debt, it is the interest rate that makes the accrued debt grows faster than most people and organizations realize.
This is actually one of the main causes of the current world wide financial crisis, the same holds for many IT debts.
And for all kinds of debts, you often don’t know how high the interest rate will be, so the accrued value can be way beyond what you expect.
I’ve regularly seen projects collecting so much debt, that migration costs raised to thousands of hours because of it, resulting into management taking another very bad decision: rewriting the stuff from scratch. Don’t do that: Joel on Software excellently describes what happens when you do that.
What to do about it?
You might say “don’t collect debt”, but you can’t always avoid debt.
So you need to build periods where you pay off accrued debt. And you need to do that regularly, in order to avoid the interest pitfall.
This does not limit itself to software development (though that’s what I normally focus at). It covers a wide range of IT topics.
Sometimes, you can even pay your debt in advance. For instance, I was among the first to switch from Windows XP to the x64 of Windows Vista. I knew it would cause pain, but it immediately payed back by being able to use much more memory, and run more Virtual Machines at the same time. That made me more flexible and productive.
–jeroen
via: Coding Horror: Paying Down Your Technical Debt.
Like this:
Be the first to like this post.
Posted in *nix, .NET, Delphi, Development, Opinions, Power User, Software Development, Windows, Windows 7, Windows 8, Windows Vista, Windows XP | 5 Comments »
Posted by jpluimers on 2012/04/03
Quite a few projects have one or more classes with with a bunch of public const string or public static readonly string values. Use const when things are really constant (like registry configuration keys), use static readonly when – upon change – I do not want to recompile dependent assemblies. Many people recommend static readonly over const.
Having members in stead of string literals scattered all over the place allows you to do compile timing checking, which I’m a big fan of as in the age of things getting more and more dynamic, you need to have as many sanity checks as possible.
One of the checks is to verify these const members and their values. Sometimes you need the list of members, sometimes the list of values, and sometimes each member value should be the same as the member name.
The listing below shows the code I came up with.
It works with code like this, and those can have more code and other fields (non string, non public) in them as well:
namespace bo.Literals
{
public class FooBarPublicStringConstants
{
public const string Foo = "Foo";
public const string Bar = "Bar";
}
public class FooBarPublicStaticReadOnlyStringFields
{
public static readonly string Foo = "Foo";
public static readonly string Bar = "Bar";
}
}
I started out with this code, but that is limited to classes only having public const fields. Not flexible enough. Read the rest of this entry »
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2012/04/02
I’m in the midst of writing a small app that generates trees and clouds of the WordPress categories.
The main reason is that I want to better organize the categories, so I need an overview. The multi-page WordPress Categories editor isn’t of much use as it is very hard to get an overview.
Using the [Category] WordPress tag isn’t of much help as I can’t get things like this to work (I remember seeing something like this on the forums, can’t find it any more though):
[Category]
[Category number='5' method='title' order='asc' id='11,45' orderby='comment_count']
Preliminary output is at the Posting Categories page in the top menu that I will update every once in a while.
I will post the app later, as I intend to create a category cloud in addition to the tree.
–jeroen
Like this:
Be the first to like this post.
Posted in Development, SocialMedia, Software Development, Web Development, WordPress, WordPress | Leave a Comment »
Posted by jpluimers on 2012/04/01
At 9 years of age, PEP 313 still is a classic april fools joke. One of the hilarious parts:
This PEP is rejected. While the majority of Python users deemed this to be a nice-to-have feature, the community was unable to reach a consensus on whether nine should be represented as IX, the modern form, or VIIII, the classic form. Likewise, no agreement was reached on whether MXM or MCMXC would be considered a well-formed representation of 1990. A vocal minority of users has also requested support for lower-cased numerals for use in (i) powerpoint slides, (ii) academic work, and (iii) Perl documentation.
–jeroen (who also loves the San Seriffe joke of 1997)
via: PEP 313 — Adding Roman Numeral Literals to Python.
Like this:
Be the first to like this post.
Posted in Development, Opinions, PHP, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2012/03/29
August 2011, Microsoft re-issued KB2251481. They should not have done that, because if you have the original KB2251481 installed (also known as KB2251481.T369_32ToU865_32) you need to go through the hoopla below to uninstall it.
In stead, they should have released a new version that automatically uninstalls a previously installed one, then installs itself.
It is not the first patch that Microsoft did wrong, but this one is the “Microsoft Visual Studio 2005 Service Pack 1 XML Editor Security Update”. Every now and then I come across it when doing work on some archived virtual machines that contain Visual Studio 2005 (which I used a lot in the past, and occasionally still use for doing some maintenance work for clients that long ago ditched stuff they thought they’d never need to use again).
The really stupid thing is the error message you get when it cannot get installed: John Doe user will never find out why it failed, let alone figure out how to get it install properly.
This is the message you will see:
[Automatic Updates]
Some updates could not be installed
The following updates were note installed:
Security Update for Microsoft Visual Studio 2005 Service Pack 1 XML Editor (KB2251481)
[Close]
The message doesn’t even include that it is trying to install the August 2011 version (hinting that there might be an earlier version you need to uninstall). Read the rest of this entry »
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, Development, Software Development, Visual Studio 2005, Visual Studio and tools | Leave a Comment »
Posted by jpluimers on 2012/03/28
Duh, I always thought @ could only be used for strings.
Not so: just like with the & in Delphi, you can use @ for identifiers too.
The prefix “@” enables the use of keywords as identifiers, which is useful when interfacing with other programming languages. The character @ is not actually part of the identifier, so the identifier might be seen in other languages as a normal identifier, without the prefix. An identifier with an @ prefix is called a verbatim identifier.
–jeroen
via: naming – What’s the use/meaning of the @ character in variable names in C#? – Stack Overflow.
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2012/03/27
So I won’t forget: a GetName method returning the name of a parameter, local or field.
Tags: C#, reflection, IL parsing, argument name, anonymous type, generic type cache, generic type caching.
–jeroen
via: reflection – C# – Resolving a parameter name at runtime – Stack Overflow.
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Development, Software Development | 1 Comment »
Posted by jpluimers on 2012/03/26
There are so many Unicode code points, that finding back one based on how a glyph looks like is similar to finding the needle in a haystack.
ShapeCatcher.com to the rescue: it has a drawing box where you can draw the glyph, and a recognition engine that presents you with Unicode code points that have a similar glyph.
Draw something in the left box!
And let shapecatcher help you to find the most similar unicode characters!
–jeroen
via: Shapecatcher.com: Unicode Character Recognition.
Like this:
Be the first to like this post.
Posted in Development, Encoding, LifeHacker, Power User, Software Development, Unicode | Leave a Comment »