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/a12188cd Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/a12188cd Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/a12188cd Branch: refs/heads/trunk Commit: a12188cd4e6fcef496480fdb9127b26aeb33b589 Parents: 6be8346 Author: Paulo Motta <pauloricard...@gmail.com> Authored: Wed Feb 17 15:25:59 2016 -0300 Committer: Jason Brown <jasedbr...@gmail.com> Committed: Wed Feb 24 05:46:08 2016 -0800 ---------------------------------------------------------------------- CHANGES.txt | 1 + bin/cqlsh.py | 12 ++++-------- conf/cqlshrc.sample | 3 ++- 3 files changed, 7 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/a12188cd/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 361eedc..1d8664c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -62,6 +62,7 @@ Merged from 2.2: * Fix paging on DISTINCT queries repeats result when first row in partition changes (CASSANDRA-10010) * (cqlsh) Support timezone conversion using pytz (CASSANDRA-10397) + * cqlsh: change default encoding to UTF-8 (CASSANDRA-11124) Merged from 2.1: * Don't remove FailureDetector history on removeEndpoint (CASSANDRA-10371) * Only notify if repair status changed (CASSANDRA-11172) http://git-wip-us.apache.org/repos/asf/cassandra/blob/a12188cd/bin/cqlsh.py ---------------------------------------------------------------------- diff --git a/bin/cqlsh.py b/bin/cqlsh.py index 3d7ea5d..c174346 100644 --- a/bin/cqlsh.py +++ b/bin/cqlsh.py @@ -217,9 +217,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).' @@ -760,10 +759,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() @@ -2446,7 +2441,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) @@ -2559,6 +2554,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/a12188cd/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.