FormatException on SQLiteConnection.Open() with custom integer format in Windows settings

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

FormatException on SQLiteConnection.Open() with custom integer format in Windows settings

David Rickard
To reproduce:

   - access *Control Panel > Region and Language*
   - ensure you are under the [ Formats ] tab and click [ Additional
   settingsā€¦ ] at bottom right
   - ensure you are under the [ Numbers ] tab and place the cursor in the
   "Negative sign symbol" field
   - replace the default hyphen-minus character ( Ascii code 45 or 2D hex )
   with a Unicode true minus character ( hold down *Alt* and type *+2212*
   on the numeric keypad )
   - Try to call SQLiteConnection.Open()

You get a System.FormatException thrown out of the method.

I took a look at the source and it's because of these lines:

                  strValue = FindKey(opts, "Cache Size",
DefaultCacheSize.ToString());
                  intValue = Convert.ToInt32(strValue,
CultureInfo.InvariantCulture);

DefaultCacheSize is -2000, so it spits out whatever you've put in for the
"Negative sign symbol", and Convert.ToInt32 chokes on the weird string. All
the built-in cultures format the negative number the same way, so you don't
see the problem unless you've mucked with these settings. The fix would be
to supply CultureInfo.InvariantCulture on all of those int.ToString() calls
so they can be properly parsed back in.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Loading...