Posts Tagged ‘convert’


Convert Ip Address To Geographic Location

网上有不少关于如何使用纯真IP数据库(QQWRY.dat),来查找IP所在的地理位置的文档和源代码,但基本都是java实现,很少有C的,而且大部分都使用了打开文件句柄,通过文件指针的多次跳转来实现单次查找,运行效率很低,尤其是在短时间内需要执行大量IP->地理位置的转换的场合,这种方式的运行性能基本是难以接受的。

Continue Reading...

October 12th, 2006 in Programming | 4 comments


Convert Unicode To UTF8

char* __stdcall UnicodeToUtf8( const WCHAR* wstr )
{
    const WCHAR* w;
    // Convert unicode to utf8
    int len = 0;
    for ( w = wstr; *w; w++ ) {

        if ( *w < 0×0080 ) len++;
        else if ( *w < 0×0800 ) len += 2;
        else len += 3;
    }

Continue Reading...

September 24th, 2006 in Programming | 22 comments