From 66f4ea4ae6665f49cbfdfa09734a0d53b2c6f3fa Mon Sep 17 00:00:00 2001 From: brianb Date: Sat, 6 Mar 2004 05:14:39 +0000 Subject: [PATCH] new file for unicode convert --- src/libmdb/iconv.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/libmdb/iconv.c diff --git a/src/libmdb/iconv.c b/src/libmdb/iconv.c new file mode 100644 index 0000000..2d8e3d0 --- /dev/null +++ b/src/libmdb/iconv.c @@ -0,0 +1,65 @@ +/* MDB Tools - A library for reading MS Access database files + * Copyright (C) 2000 Brian Bruns + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "mdbtools.h" + +#ifdef DMALLOC +#include "dmalloc.h" +#endif + +int +mdb_unicode2ascii(MdbHandle *mdb, unsigned char *buf, int offset, int len, char *dest) +{ + int i; + + if (buf[offset]==0xff && buf[offset+1]==0xfe) { + strncpy(dest, &buf[offset+2], len-2); + dest[len-2]='\0'; + } else { + /* convert unicode to ascii, rather sloppily */ + for (i=0;i