Split out database functions, remove dependence on wine/unicode.h.