gnucash maint: Use scm_from_locale_string for converting command-line input.

John Ralls jralls at code.gnucash.org
Sat Aug 8 18:02:01 EDT 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/e8da10ba (commit)
	from  https://github.com/Gnucash/gnucash/commit/ff318255 (commit)



commit e8da10ba2ea3ca6c2b47dc2c4d96b905f80e22c9
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Aug 8 15:01:33 2020 -0700

    Use scm_from_locale_string for converting command-line input.
    
    Because Windows generally can't enter UTF8 on the command line.

diff --git a/gnucash/gnucash-commands.cpp b/gnucash/gnucash-commands.cpp
index feb975dd5..87a1995cb 100644
--- a/gnucash/gnucash-commands.cpp
+++ b/gnucash/gnucash-commands.cpp
@@ -182,11 +182,18 @@ scm_run_report (void *data,
     auto check_report_cmd = scm_c_eval_string ("gnc:cmdline-check-report");
     auto get_report_cmd = scm_c_eval_string ("gnc:cmdline-get-report-id");
     auto run_export_cmd = scm_c_eval_string ("gnc:cmdline-template-export");
-    auto report = scm_from_utf8_string (args->run_report.c_str());
+    /* We generally insist on using scm_from_utf8_string() throughout GnuCash
+     * because all GUI-sourced strings and all file-sourced strings are encoded
+     * that way. In this case, though, the input is coming from a shell window
+     * and Microsoft Windows shells are generally not capable of entering UTF8
+     * so it's necessary here to allow guile to read the locale and interpret
+     * the input in that encoding.
+     */
+    auto report = scm_from_locale_string (args->run_report.c_str());
     auto type = !args->export_type.empty() ?
-                scm_from_utf8_string (args->export_type.c_str()) : SCM_BOOL_F;
+                scm_from_locale_string (args->export_type.c_str()) : SCM_BOOL_F;
     auto file = !args->output_file.empty() ?
-                scm_from_utf8_string (args->output_file.c_str()) : SCM_BOOL_F;
+                scm_from_locale_string (args->output_file.c_str()) : SCM_BOOL_F;
 
 /* dry-run? is #t: try report, check validity of options */
     if (scm_is_false (scm_call_3 (check_report_cmd, report, type, file)))
@@ -271,7 +278,7 @@ scm_report_show (void *data,
     }
 
     scm_call_2 (scm_c_eval_string ("gnc:cmdline-report-show"),
-                scm_from_utf8_string (args->show_report.c_str ()),
+                scm_from_locale_string (args->show_report.c_str ()),
                 scm_current_output_port ());
     gnc_shutdown (0);
     return;



Summary of changes:
 gnucash/gnucash-commands.cpp | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)



More information about the gnucash-changes mailing list