summary refs log tree commit diff stats
path: root/test/tc_utfwidth.py
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-05-04 23:29:54 +0200
committerhut <hut@lavabit.com>2010-05-10 21:04:47 +0200
commitccbe8b8d13ebdad09d282da51d118670a566cba5 (patch)
tree469773a104a0aeb0a995f5d2acd9f9a91fb635c0 /test/tc_utfwidth.py
parent338bbba4a14a21c82a3d4849b075fddddad9cee9 (diff)
downloadranger-ccbe8b8d13ebdad09d282da51d118670a566cba5.tar.gz
attempt to fix utf issues (wrong calculation of width)
Diffstat (limited to 'test/tc_utfwidth.py')
-rw-r--r--test/tc_utfwidth.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/tc_utfwidth.py b/test/tc_utfwidth.py
new file mode 100644
index 00000000..cf564990
--- /dev/null
+++ b/test/tc_utfwidth.py
@@ -0,0 +1,42 @@
+# -*- encoding: utf8 -*-
+# Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+if __name__ == '__main__': from __init__ import init; init()
+
+from unittest import TestCase, main
+from ranger.ext.utfwidth import *
+
+a_ascii = "a"      # width = 1, bytes = 1
+a_umlaut = "ä"     # width = 1, bytes = 2
+a_katakana = "ア"  # width = 2, bytes = 3
+# need one with width = 1 & bytes = 3
+
+class Test(TestCase):
+	def test_utf_byte_length(self):
+		self.assertEqual(1, utf_byte_length(a_ascii[0]))
+		self.assertEqual(2, utf_byte_length(a_umlaut[0]))
+		self.assertEqual(3, utf_byte_length(a_katakana[0]))
+
+	def test_uwid(self):
+		self.assertEqual(1, uwid(a_ascii))
+		self.assertEqual(1, uwid(a_umlaut))
+		self.assertEqual(2, uwid(a_katakana))
+		self.assertEqual(3, uwid(a_katakana + a_umlaut))
+		self.assertEqual(4, uwid("asdf"))
+		self.assertEqual(5, uwid("löööl"))
+		self.assertEqual(6, uwid("バババ"))
+
+if __name__ == '__main__': main()
ous revision' href='/danisanti/profani-tty/blame/src/tools/http_upload.h?id=28e260c7da7bddebcb7b08003174eb16b9a6f596'>^
4711fc62 ^



1b0ce852 ^

4711fc62 ^





1b0ce852 ^

e217ed0b ^




1b0ce852 ^

a2726b6a ^
1b0ce852 ^
39c32906 ^

1b0ce852 ^
a2726b6a ^

9be7d29f ^
1b0ce852 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77

                
                                 
  
                                                            













                                                                       
                                                                      

















                                                                                



                      
                       
                      
 
                         
 



                            

                          





                       

                     




                                                  

             
                                    
 

                                                 
 

                                                   
 
      
/*
 * http_upload.h
 * vim: expandtab:ts=4:sts=4:sw=4
 *
 * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
 *
 * This file is part of Profanity.
 *
 * Profanity is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Profanity 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Profanity.  If not, see <https://www.gnu.org/licenses/>.
 *
 * In addition, as a special exception, the copyright holders give permission to
 * link the code of portions of this program with the OpenSSL library under
 * certain conditions as described in each individual source file, and
 * distribute linked combinations including the two.
 *
 * You must obey the GNU General Public License in all respects for all of the
 * code used other than OpenSSL. If you modify file(s) with this exception, you
 * may extend this exception to your version of the file(s), but you are not
 * obligated to do so. If you do not wish to do so, delete this exception
 * statement from your version. If you delete this exception statement from all
 * source files in the program, then also delete it here.
 *
 */

#ifndef TOOLS_HTTP_UPLOAD_H
#define TOOLS_HTTP_UPLOAD_H

#ifdef PLATFORM_CYGWIN
#define SOCKET int
#endif

#include <sys/select.h>
#include <curl/curl.h>

#include "ui/win_types.h"

typedef struct http_upload_t
{
    char* filename;
    FILE* filehandle;
    off_t filesize;
    curl_off_t bytes_sent;
    char* mime_type;
    char* get_url;
    char* put_url;
    char* alt_scheme;
    char* alt_fragment;
    ProfWin* window;
    pthread_t worker;
    int cancel;
    // Additional headers
    // (NULL if they shouldn't be send in the PUT)
    char* authorization;
    char* cookie;
    char* expires;
} HTTPUpload;

void* http_file_put(void* userdata);

char* file_mime_type(const char* const filename);
off_t file_size(int filedes);

void http_upload_cancel_processes(ProfWin* window);
void http_upload_add_upload(HTTPUpload* upload);

#endif