db4o Developer Community
Developer Community db4o open source object database, native to Java and .NET
Register   |  Login
  Search
  • Forums
  • Documentation
  • Resources
  • Downloads
  • Blogs
  • About

What is db4o?

Tags

  • benchmark
  • db4o-7.12
  • db4o-7.13
  • db4o-8.0
  • documentation
  • maven
  • Poleposition
  • release notes
  • source code

Archive

  • July, 2010 ( 2 )
  • June, 2010 ( 2 )
  • May, 2010 ( 5 )
  • February, 2010 ( 1 )
  • January, 2010 ( 3 )
  • November, 2009 ( 3 )
  • October, 2009 ( 6 )
  • September, 2009 ( 1 )
  • August, 2009 ( 3 )
  • June, 2009 ( 4 )
  • May, 2009 ( 3 )
  • March, 2009 ( 5 )
  • February, 2009 ( 1 )
  • January, 2009 ( 4 )
  • December, 2008 ( 1 )
  • November, 2008 ( 4 )
  • October, 2008 ( 2 )
  • September, 2008 ( 3 )
  • August, 2008 ( 3 )
  • July, 2008 ( 4 )
  • June, 2008 ( 3 )
  • May, 2008 ( 2 )
  • April, 2008 ( 5 )
  • February, 2008 ( 5 )
  • January, 2008 ( 6 )
  • December, 2007 ( 1 )
  • November, 2007 ( 4 )
  • October, 2007 ( 4 )
  • September, 2007 ( 3 )
  • August, 2007 ( 2 )
  • July, 2007 ( 2 )
  • June, 2007 ( 1 )
  • May, 2007 ( 6 )
  • April, 2007 ( 3 )
  • March, 2007 ( 3 )
  • February, 2007 ( 1 )
  • January, 2007 ( 1 )
  • December, 2006 ( 3 )
  • November, 2006 ( 10 )
  • October, 2006 ( 2 )
  • September, 2006 ( 2 )
  • August, 2006 ( 2 )
  • July, 2006 ( 4 )
  • June, 2006 ( 5 )
  • May, 2006 ( 6 )
  • April, 2006 ( 4 )
  • February, 2006 ( 3 )
  • Home
  • Rss Feed

New pluggable StringEncoding interface

Posted @ 10/9/2008 1:21 PM By Carl Rosenberger
Posted in | 0 Comments

When db4o stores and loads strings it has to convert them to and from bytes. Until recently db4o only used to supply 2 encodings to do this work:
One for 16-bit Unicode, the other for ISO 8859-1. To decide for one or the other you would call Configuration#unicode() and pass true for Unicode and false for ISO 8859-1.

To supply more encodings and to allow the creation of own string encodings we deprecated the old configuration interface and supply a new one. Now you can either use one of the built-in encodings from the StringEncodings class or pass your own encoding. Examples:

Configuration config = Db4o.newConfiguration();
config.stringEncoding(StringEncodings.utf8());
Db4o.openFile(config, "myDB.db4o");

or

Configuration config = Db4o.newConfiguration();
config.stringEncoding(new StringEncoding() {
	public byte[] encode(String str) {
		// TODO: implement
		return null;
	}
	public String decode(byte[] bytes, int start, int length) {
		// TODO: implement
		return null;
	}
});
Db4o.openFile(config, "myDB.db4o");

Please note that you should configure the string encoding before you create the database file, in the first call to #openFile() or #openServer(). If you use one of the built-in encodings, db4o will remember the encoding for all subsequent open calls. If you use a StringEncoding class that you have written yourself, you have to supply the same StringEncoding and configure it for all subsequent open calls, otherwise db4o will not be able to read and write strings correctly. Since db4o also uses the string encodings for metadata like classnames and fieldnames, you are likely to notice any misconfiguration very quickly by not being able to read any objects at all.

The StringEncoding used has to stay the same for the lifetime of a database.

Although we keep the Unicode string encoding as the standard setting, we encourage the use of the new built-in UTF-8 string encoding for smaller and faster database files.

We also hope that the pluggable interface will be useful for you, especially if you want db4o to work with Chinese or Japanese character sets.

Enjoy!

 

 Share |
Return TopTrackbackPrintPermalink
Previous Entry: LINQ for the Compact Framework 3.5
Next Entry: New fast collection implementation for huge sets: BigSet

Comments

Was it good for you, too?Join the discussion » ,but you need to login first before you make comments.
    On processing, please waiting for ...
    Copyright ©2000-2010 by Versant Corp.
    Privacy Policy