You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ja...@apache.org on 2016/02/24 14:47:06 UTC

[2/7] cassandra git commit: cqlsh: change default encoding to UTF-8

cqlsh: change default encoding to UTF-8

patch by Paulo Motta; reviewed by Stefania Alborghetti for CASSANDRA-11124


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/66b0d3f0
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/66b0d3f0
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/66b0d3f0

Branch: refs/heads/cassandra-3.0
Commit: 66b0d3f016c5ca3c167960a8f7bbef815c95363f
Parents: 77ff794
Author: Paulo Motta <pa...@gmail.com>
Authored: Wed Feb 17 15:25:59 2016 -0300
Committer: Jason Brown <ja...@gmail.com>
Committed: Wed Feb 24 05:43:00 2016 -0800

----------------------------------------------------------------------
 CHANGES.txt         |  2 +-
 bin/cqlsh.py        | 12 ++++--------
 conf/cqlshrc.sample |  3 ++-
 3 files changed, 7 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/66b0d3f0/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index e989e7f..9162165 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -30,7 +30,7 @@ Merged from 2.1:
  * Make it clear what DTCS timestamp_resolution is used for (CASSANDRA-11041)
  * test_bulk_round_trip_blogposts is failing occasionally (CASSANDRA-10938)
  * (cqlsh) Support timezone conversion using pytz (CASSANDRA-10397)
-
+ * cqlsh: change default encoding to UTF-8 (CASSANDRA-11124)
 
 2.2.5
  * maxPurgeableTimestamp needs to check memtables too (CASSANDRA-9949)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/66b0d3f0/bin/cqlsh.py
----------------------------------------------------------------------
diff --git a/bin/cqlsh.py b/bin/cqlsh.py
index 6a464b0..c82a294 100644
--- a/bin/cqlsh.py
+++ b/bin/cqlsh.py
@@ -209,9 +209,8 @@ parser.add_option('-k', '--keyspace', help='Authenticate to the given keyspace.'
 parser.add_option("-f", "--file", help="Execute commands from FILE, then exit")
 parser.add_option('--debug', action='store_true',
                   help='Show additional debugging information')
-parser.add_option("--encoding", help="Specify a non-default encoding for output.  If you are " +
-                  "experiencing problems with unicode characters, using utf8 may fix the problem." +
-                  " (Default from system preferences: %s)" % (locale.getpreferredencoding(),))
+parser.add_option("--encoding", help="Specify a non-default encoding for output." +
+                  " (Default: %s)" % (UTF8,))
 parser.add_option("--cqlshrc", help="Specify an alternative cqlshrc file location.")
 parser.add_option('--cqlversion', default=DEFAULT_CQLVER,
                   help='Specify a particular CQL version (default: %default).'
@@ -737,10 +736,6 @@ class Shell(cmd.Cmd):
         self.session.max_trace_wait = max_trace_wait
 
         self.tty = tty
-        if encoding is None:
-            encoding = locale.getpreferredencoding()
-            if encoding is None:
-                encoding = UTF8
         self.encoding = encoding
         self.check_windows_encoding()
 
@@ -2358,7 +2353,7 @@ def read_options(cmdlineargs, environment):
     optvalues.debug = False
     optvalues.file = None
     optvalues.ssl = False
-    optvalues.encoding = None
+    optvalues.encoding = option_with_default(configs.get, 'ui', 'encoding', UTF8)
 
     optvalues.tty = option_with_default(configs.getboolean, 'ui', 'tty', sys.stdin.isatty())
     optvalues.cqlversion = option_with_default(configs.get, 'cql', 'version', DEFAULT_CQLVER)
@@ -2471,6 +2466,7 @@ def main(options, hostname, port):
     if options.debug:
         sys.stderr.write("Using CQL driver: %s\n" % (cassandra,))
         sys.stderr.write("Using connect timeout: %s seconds\n" % (options.connect_timeout,))
+        sys.stderr.write("Using '%s' encoding\n" % (options.encoding,))
 
     # create timezone based on settings, environment or auto-detection
     timezone = None

http://git-wip-us.apache.org/repos/asf/cassandra/blob/66b0d3f0/conf/cqlshrc.sample
----------------------------------------------------------------------
diff --git a/conf/cqlshrc.sample b/conf/cqlshrc.sample
index a0012a3..462dcc6 100644
--- a/conf/cqlshrc.sample
+++ b/conf/cqlshrc.sample
@@ -42,7 +42,8 @@
 ;; Used for automatic completion and suggestions
 ; completekey = tab
 
-
+;; The encoding used for characters
+; encoding = utf8
 
 ; To use another than the system default browser for cqlsh HELP to open
 ; the CQL doc HTML, use the 'browser' preference.