[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Monotone-devel] monotone rosterify charset correction (latin->utf8)
From: |
Christof Petig |
Subject: |
[Monotone-devel] monotone rosterify charset correction (latin->utf8) |
Date: |
Tue, 05 Dec 2006 17:59:49 +0100 |
User-agent: |
Thunderbird 1.5.0.8 (X11/20061115) |
Hi,
I just wanted to share this piece of code with you:
it will assume that every pre-roster and non-utf8 filename is actually
latin1 encoded and fix it.
Useful if rosterify gives you errors about non-utf-8-file names.
Christof
============================================================
--- legacy.cc 6867f219f457fa5df90b2801871c1e1f61a451f0
+++ legacy.cc 7c636d8554d63f2c79dbcc497d3b821130d73ef8
@@ -11,6 +11,7 @@
#include "basic_io.hh"
#include "app_state.hh"
#include "constants.hh"
+#include "charset.hh"
using std::make_pair;
using std::string;
@@ -163,6 +164,21 @@ namespace legacy
file_name = dat().substr(file_name_begin);
else
file_name = dat().substr(file_name_begin, pos - file_name_begin);
+ if (!utf8_validate(file_name))
+ {
+ // assume latin1
+ std::string tmp;
+ for (std::string::const_iterator
i=file_name.begin();i!=file_name.end();++i)
+ {
+ if ((*i&0x80))
+ {
+ tmp+=0xc0|((*i>>6)&3);
+ tmp+=0x80|(*i&0x3c);
+ }
+ else tmp+=*i;
+ }
+ file_name=tmp;
+ }
man.insert(make_pair(file_path_internal(file_name),
hexenc<id>(ident)));
// skip past the '\n'
============================================================
signature.asc
Description: OpenPGP digital signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Monotone-devel] monotone rosterify charset correction (latin->utf8),
Christof Petig <=