[ 
https://issues.apache.org/jira/browse/CASSANDRA-10875?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15063908#comment-15063908
 ] 

Paulo Motta edited comment on CASSANDRA-10875 at 12/18/15 12:45 PM:
--------------------------------------------------------------------

bq. Furthermore, cqlsh --encoding=utf8 doesn't seem to work correctly.

You're right. Although the encoding is correctly used for encoding the output, 
it's not being used to decode the input (which uses ascii by default).

The use of {{sys.setdefaultencoding('utf-8')}} is 
[discouraged|http://blog.notdot.net/2010/07/Getting-unicode-right-in-Python]. 
Can you try the following approach?

{noformat}
diff --git a/bin/cqlsh b/bin/cqlsh
index 651420d..115cc09 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -929,7 +929,7 @@ class Shell(cmd.Cmd):
 
     def get_input_line(self, prompt=''):
         if self.tty:
-            self.lastcmd = raw_input(prompt)
+            self.lastcmd = raw_input(prompt).decode(self.encoding)
             line = self.lastcmd + '\n'
         else:
             self.lastcmd = self.stdin.readline()
{noformat}

If it works, please provide patches for 2.1, 2.2, 3.0 and trunk (if they don't 
merge up correctly).



was (Author: pauloricardomg):
bq. Furthermore, cqlsh --encoding=utf8 doesn't seem to work correctly.

You're right. Although the encoding is correctly used for encoding the output, 
it's not being used to decode the input (which uses ascii by default).

The use of . Can you try the following approach?


> cqlsh fails to decode utf-8 characters for text typed columns.
> --------------------------------------------------------------
>
>                 Key: CASSANDRA-10875
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-10875
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Tools
>            Reporter: Yasuharu Goto
>            Assignee: Yasuharu Goto
>            Priority: Minor
>             Fix For: 2.1.13, 3.1
>
>         Attachments: 10875-2.1.12.txt, 10875-3.1.txt
>
>
> Hi, we've found a bug that cqlsh can't handle unicode text in select 
> conditions even if it were text type.
> {noformat}
> $ ./bin/cqlsh
> Connected to Test Cluster at 127.0.0.1:9042.
> [cqlsh 5.0.1 | Cassandra 3.2-SNAPSHOT | CQL spec 3.3.1 | Native protocol v4]
> Use HELP for help.
> cqlsh> create KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 
> 'replication_factor': 1};
> cqlsh> create table test.test(txt text primary key);
> cqlsh> insert into test.test (txt) values('日本語');
> cqlsh> select * from test.test where txt='日本語';
> 'ascii' codec can't decode byte 0xe6 in position 35: ordinal not in range(128)
> cqlsh> 
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to