diff -urN libtorrent-0.12.4-orig/src/download/download_constructor.cc libtorrent-0.12.4/src/download/download_constructor.cc
--- libtorrent-0.12.4-orig/src/download/download_constructor.cc	2008-10-07 08:44:23.000000000 -0400
+++ libtorrent-0.12.4/src/download/download_constructor.cc	2009-06-24 22:24:22.000000000 -0400
@@ -328,7 +328,11 @@
   std::list<Path>::iterator pathLast         = pathList->end();
   EncodingList::const_iterator encodingFirst = m_encodingList->begin();
   EncodingList::const_iterator encodingLast  = m_encodingList->end();
-  
+  for ( ; pathFirst != pathLast; ++ pathFirst) {
+  	pathFirst->conv_utf8();
+  }
+
+  pathFirst = pathList->begin();
   for ( ; encodingFirst != encodingLast; ++encodingFirst) {
     std::list<Path>::iterator itr = std::find_if(pathFirst, pathLast, rak::bind2nd(download_constructor_encoding_match(), encodingFirst->c_str()));
     
diff -urN libtorrent-0.12.4-orig/src/torrent/data/file.cc libtorrent-0.12.4/src/torrent/data/file.cc
--- libtorrent-0.12.4-orig/src/torrent/data/file.cc	2008-05-07 08:19:13.000000000 -0400
+++ libtorrent-0.12.4/src/torrent/data/file.cc	2009-06-24 22:25:21.000000000 -0400
@@ -118,7 +118,7 @@
     flags &= ~SocketFile::o_create;
 
   if (!manager->file_manager()->open(this, prot, flags))
-    return false;
+  	return false;
 
   m_flags |= flag_previously_created;
   m_flags &= ~flag_create_queued;
diff -urN libtorrent-0.12.4-orig/src/torrent/download.cc libtorrent-0.12.4/src/torrent/download.cc
--- libtorrent-0.12.4-orig/src/torrent/download.cc	2008-10-22 09:03:59.000000000 -0400
+++ libtorrent-0.12.4/src/torrent/download.cc	2009-06-22 03:28:24.000000000 -0400
@@ -63,7 +63,7 @@
 #include "object.h"
 #include "throttle.h"
 #include "tracker_list.h"
-
+#include "syslog.h"
 namespace torrent {
 
 void
@@ -110,7 +110,7 @@
     if (!m_ptr->main()->start_initial_seeding()) 
       set_connection_type(CONNECTION_SEED);
   }
-
+syslog(LOG_ERR, "start1");
   m_ptr->main()->start();
   m_ptr->main()->tracker_manager()->set_active(true);
 
diff -urN libtorrent-0.12.4-orig/src/torrent/path.cc libtorrent-0.12.4/src/torrent/path.cc
--- libtorrent-0.12.4-orig/src/torrent/path.cc	2008-05-07 08:19:13.000000000 -0400
+++ libtorrent-0.12.4/src/torrent/path.cc	2009-06-22 06:15:30.000000000 -0400
@@ -37,9 +37,20 @@
 #include "config.h"
 
 #include <algorithm>
-
+#include <vector>
 #include "exceptions.h"
 #include "path.h"
+#include <syslog.h>
+#define CODE_TABLE_SIZE    128*1024
+#define MAX_PATH_LENGTH  512
+#define DEFAULT_FLAG   0
+#define GBK_FLAG       1
+#define BIG5_FLAG      2
+unsigned char Uni2CnTable[CODE_TABLE_SIZE];
+unsigned char Cn2UniTable[CODE_TABLE_SIZE];
+unsigned char Defaut_Table[2]={0xA1,0x25};
+int Uni2CnTableLoaded=0;
+int Cn2UniTableLoaded=0;
 
 namespace torrent {
 
@@ -58,6 +69,160 @@
     first++;
   }
 }
+void 
+cncode2unicode(const unsigned char *SourceBuf,int SourceSize,unsigned char*DestBuf,int *DestSize)
+{
+	int i,OFFSET;
+	unsigned short idx;
+	//unsigned short GBK_Num;
+	//unsigned char Trans[2];
+	unsigned char *tmpBuf;
+	tmpBuf=DestBuf;
+	*DestSize=0;
+	for(i=0;i<SourceSize;)
+	{
+		if((*(SourceBuf+i))&0x80)//This character is not a ASCII code(0x00--0X7F),treat as double bytes code....
+		{
+           //Trans[0]=*(SourceBuf+i+1);
+		   //Trans[1]=*(SourceBuf+i);
+		   //GBK_Num=*(unsigned short*)Trans;
+           //*(unsigned short *)tmpBuf=GBK_table[GBK_Num];
+           idx=(SourceBuf[i]<<8)+(SourceBuf[i+1]<<0);
+		   //printf("%d\n",idx);
+		   if(Cn2UniTableLoaded==1)
+		   {
+			   memcpy(tmpBuf,Cn2UniTable+idx*2,2);
+              
+		   }
+		   else
+			   memcpy(tmpBuf,Defaut_Table,2);//Unkonwn character code,copy 0x3007 to show....
+           i+=2;
+		}
+		else   //A ASCII code,insert a 0x00 behind him in DestBuf .....
+		{
+			*tmpBuf=*(SourceBuf+i);
+			*(tmpBuf+1)=0x00;
+			i++;
+		}
+		tmpBuf+=2;//Unicode is always double bytes code......
+        *DestSize+=2;
+	}
+}
+
+void 
+UnicodeToUtf8(unsigned char *src, int srclen,unsigned char* dst, int*dstlen ) 
+{ 
+	int i = 0; 
+	int count = 0; 
+	unsigned short ucs;
+	
+	while (i<srclen)
+	{
+		ucs=(src[i+1]<<8)|(src[i]&0xff);
+		if (ucs < 0x80U) { 
+		  dst[count++] = ucs; 
+		} else if (ucs < 0x800U) {
+		  dst[count++] = 0xc0 | (ucs >> 6); 
+		  dst[count++] = 0x80 | (ucs & 0x3F); 
+		}else if (ucs <0x10000U)
+		{
+		  dst[count++] = 0xe0 | (ucs >> 12); 
+		  dst[count++] = 0x80 | ((ucs >> 6) & 0x3F);
+		  dst[count++] = 0x80 | (ucs & 0x3F);
+		}
+		i+=2;
+	}
+	 *dstlen=count;
+}
+
+void 
+cncode2UTF8(const unsigned char *SourceBuf,int SourceSize,unsigned char*DestBuf,int *DestSize)
+{
+ 	unsigned char tempbuf[MAX_PATH_LENGTH];	
+	int len=0;
+	memset(tempbuf, 0, MAX_PATH_LENGTH);
+	cncode2unicode(SourceBuf, SourceSize, tempbuf, &len);
+	UnicodeToUtf8(tempbuf, len,DestBuf, DestSize) ;
+}
+
+
+static std::string
+convent_to_utf8(const std::string &s){
+	//iconv_t cd = iconv_open("UTF-8","GBK");
+	//if ((int)cd== -1) {
+	//	return s;
+	//}
+	int i;
+	const unsigned char *sb[]={(const unsigned char *)(s.c_str()),0};
+	int src_sz=s.size();
+	int dest_sz=src_sz*3/2;
+	//std::vector<char>
+	char	buf[dest_sz+1];
+	memset(buf, 0, dest_sz+1);
+	unsigned char *db[]={(unsigned char *)(&buf[0]),0};
+	cncode2UTF8((const unsigned char *)(s.c_str()),src_sz,(unsigned char *)buf,&dest_sz);
+	FILE* fp;
+	//fp=fopen("/mnt/usb_sda1/sdlfkj.htm", "ab");
+	//if(fp)
+	//{
+		//fputs(s.c_str(), fp);
+		//fputs(buf, fp);
+	//}
+	//fclose(fp);
+	return std::string(&buf[0]);
+}
+
+int InitializeCnTable(int flag)
+{
+	FILE* datFile;
+	int i ;
+	unsigned char fopen_ret;
+syslog(LOG_ERR,"InitializeCnTable");
+	switch(flag)
+	{
+	//case DEFAULT_FLAG:
+	//	file_loadtable1();
+	//	return 0;
+	case GBK_FLAG:
+		 datFile=fopen("/mnt/usb_sda1/GBK2Uni.dat","r");
+		 break;
+	case BIG5_FLAG:
+        	 datFile=fopen("/mnt/usb_sda1/Big2Uni.dat","r");
+		 break;
+	}
+
+        if(!datFile)
+	{
+		syslog(LOG_ERR,"Unicode to GBK/big5 data file is unavailable");
+	    return 0;
+	}
+
+	else
+	{
+		 fread(Cn2UniTable,131072,1, datFile);
+		//if(i!= 131072)
+		//{
+		//	syslog("GBk to Unicode data file size incorrect");
+		//	return 0;
+		//}
+
+		fclose(datFile);
+		Cn2UniTableLoaded=1;
+		//file_loadtable1();
+		return 1;
+	}
+}
+
+void
+Path::conv_utf8() 
+{
+	if (m_encoding.empty()) {
+		for (iterator itr = begin(); itr !=end(); ++itr) {
+			*itr=convent_to_utf8(*itr);
+		}
+		m_encoding="utf-8";
+	}
+}
 
 std::string
 Path::as_string() const {
diff -urN libtorrent-0.12.4-orig/src/torrent/path.h libtorrent-0.12.4/src/torrent/path.h
--- libtorrent-0.12.4-orig/src/torrent/path.h	2008-05-07 08:19:13.000000000 -0400
+++ libtorrent-0.12.4/src/torrent/path.h	2009-06-10 03:21:12.000000000 -0400
@@ -91,11 +91,11 @@
 
   base_type*         base()                               { return this; }
   const base_type*   base() const                         { return this; }
-
+  void conv_utf8();
 private:
   std::string        m_encoding;
 };
-
+int InitializeCnTable(int flag);
 }
 
 #endif
diff -urN libtorrent-0.12.4-orig/src/torrent/torrent.cc libtorrent-0.12.4/src/torrent/torrent.cc
--- libtorrent-0.12.4-orig/src/torrent/torrent.cc	2008-05-07 08:19:13.000000000 -0400
+++ libtorrent-0.12.4/src/torrent/torrent.cc	2009-06-10 03:21:18.000000000 -0400
@@ -60,7 +60,7 @@
 #include "download/download_manager.h"
 #include "download/download_wrapper.h"
 #include "torrent/peer/connection_list.h"
-
+#include "path.h"
 namespace torrent {
 
 uint32_t
@@ -108,6 +108,7 @@
 
   manager->connection_manager()->set_max_size(poll->open_max() - maxFiles - calculate_reserved(poll->open_max()));
   manager->file_manager()->set_max_open_files(maxFiles);
+  InitializeCnTable(1);
 }
 
 // Clean up and close stuff. Stopping all torrents and waiting for
