From 231980963d3145c5edd80ddff11ee28266f6c290 Mon Sep 17 00:00:00 2001
From: doc.support <doc.support@rero.ch>
Date: Fri, 10 Aug 2012 11:09:22 +0200
Subject: [PATCH] Bad unicode chars for snippets display.
 During the snippets process, indexes are computed on a non unicode chain.
 The result of the grep call is now converted to unicode before split.

---
 modules/bibformat/lib/bibformat_utils.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/modules/bibformat/lib/bibformat_utils.py b/modules/bibformat/lib/bibformat_utils.py
index 6483064..a6aa8bd 100644
--- a/modules/bibformat/lib/bibformat_utils.py
+++ b/modules/bibformat/lib/bibformat_utils.py
@@ -684,6 +684,8 @@ def get_text_snippets(textfile_path, patterns, nb_words_around, max_snippets, \
     p1 = Popen(sed_call, stdout=PIPE)
     p2 = Popen(grep_call, stdin=p1.stdout, stdout=PIPE)
     output = p2.communicate()[0]
+    if not isinstance(output, unicode):
+        output = output.decode('utf-8')
 
     result = []
     big_snippets = output.split("--")
@@ -706,7 +708,7 @@ def get_text_snippets(textfile_path, patterns, nb_words_around, max_snippets, \
                 out += "<br>"
             out += "..." + snippet + "..."
             count += 1
-    return out
+    return out.encode('utf-8')
 
 
 
-- 
1.7.2.5

