diff --git a/CHANGES.txt b/CHANGES.txt index 9ca2f8038e..4549dedbe7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -33,6 +33,7 @@ Merged from 2.2: * (cqlsh) Support utf-8/cp65001 encoding on Windows (CASSANDRA-11030) * Fix paging on DISTINCT queries repeats result when first row in partition changes (CASSANDRA-10010) + * 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) diff --git a/bin/cqlsh.py b/bin/cqlsh.py index a4dd2530cb..8dbc1cedda 100644 --- a/bin/cqlsh.py +++ b/bin/cqlsh.py @@ -213,9 +213,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() @@ -2445,7 +2440,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) @@ -2558,6 +2553,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 diff --git a/conf/cqlshrc.sample b/conf/cqlshrc.sample index a0012a3ace..462dcc6d0a 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.