@@ -390,7 +390,6 @@ enum option_type_t
390390 F_OUTPUT_OPT = 32 , /* flag: option changes program output */
391391 F_UFLG = 1 , /* set a bit flag in a uint32_t field */
392392 F_UENC = F_UFLG | F_OUTPUT_OPT , /* an encoding changing option */
393- F_CSTR = 2 | F_NEED_PARAM , /* store parameter as a C string */
394393 F_TSTR = 3 | F_NEED_PARAM , /* store parameter as a tstr_t */
395394 F_TOUT = 4 | F_NEED_PARAM | F_OUTPUT_OPT ,
396395 F_VFNC = 5 , /* just call a function */
@@ -466,7 +465,7 @@ cmdline_opt_t cmdline_opt[] =
466465 { F_UFLG , 0 , 0 , "uppercase" , 0 , & opt .flags , OPT_UPPERCASE },
467466 { F_UFLG , 0 , 0 , "lowercase" , 0 , & opt .flags , OPT_LOWERCASE },
468467 { F_TSTR , 0 , 0 , "template" , 0 , & opt .template_file , 0 },
469- { F_CSTR , 'p' , 0 , "printf" , 0 , & opt .printf_str , 0 },
468+ { F_TSTR , 'p' , 0 , "printf" , 0 , & opt .printf_str , 0 },
470469
471470 /* other options */
472471 { F_UFLG , 'r' , 'R' , "recursive" , 0 , & opt .flags , OPT_RECURSIVE },
@@ -481,7 +480,7 @@ cmdline_opt_t cmdline_opt[] =
481480 { F_UENC , 'P' , 0 , "percents" , 0 , & opt .flags , OPT_PERCENTS },
482481 { F_UFLG , 0 , 0 , "speed" , 0 , & opt .flags , OPT_SPEED },
483482 { F_UFLG , 'e' , 0 , "embed-crc" , 0 , & opt .flags , OPT_EMBED_CRC },
484- { F_CSTR , 0 , 0 , "embed-crc-delimiter" , 0 , & opt .embed_crc_delimiter , 0 },
483+ { F_TSTR , 0 , 0 , "embed-crc-delimiter" , 0 , & opt .embed_crc_delimiter , 0 },
485484 { F_UFNC , 0 , 0 , "path-separator" , (opt_handler_t )set_path_separator , 0 , 0 },
486485 { F_TOUT , 'o' , 0 , "output" , 0 , & opt .output , 0 },
487486 { F_TOUT , 'l' , 0 , "log" , 0 , & opt .log , 0 },
@@ -571,7 +570,7 @@ static void apply_option(options_t* opts, parsed_option_t* option)
571570 }
572571 else if (option_type == F_UFNC ) {
573572 /* convert from UTF-16 to UTF-8 */
574- value = convert_wcs_to_str (tparam , ConvertToUtf8 | ConvertExact );
573+ value = convert_wcs_to_str (tparam , ConvertUtf8ToWcs | ConvertExact );
575574 } else {
576575 /* convert from UTF-16 */
577576 value = convert_wcs_to_str (tparam , ConvertToPrimaryEncoding );
@@ -590,7 +589,6 @@ static void apply_option(options_t* opts, parsed_option_t* option)
590589 case F_UENC :
591590 * (unsigned * )((char * )opts + ((char * )o -> ptr - (char * )& opt )) |= o -> param ;
592591 break ;
593- case F_CSTR :
594592 case F_TSTR :
595593 case F_TOUT :
596594 /* save the option parameter */
@@ -1069,6 +1067,18 @@ static void apply_cmdline_options(struct parsed_cmd_line_t* cmd_line)
10691067 if (!(opt .flags & OPT_RECURSIVE )) opt .find_max_depth = 0 ;
10701068 opt .search_data -> max_depth = opt .find_max_depth ;
10711069
1070+ #ifdef _WIN32
1071+ /* convert from UTF-16 to UTF-8, after choosing primary codepage */
1072+ if (opt .printf_str ) {
1073+ opt .printf_str = convert_wcs_to_str ((rsh_tchar * )opt .printf_str , ConvertToPrimaryEncoding );
1074+ rsh_vector_add_ptr (opt .mem , opt .printf_str );
1075+ }
1076+ if (opt .embed_crc_delimiter ) {
1077+ opt .embed_crc_delimiter = convert_wcs_to_str ((rsh_tchar * )opt .embed_crc_delimiter , ConvertToPrimaryEncoding );
1078+ rsh_vector_add_ptr (opt .mem , opt .embed_crc_delimiter );
1079+ }
1080+ #endif
1081+
10721082 /* set defaults */
10731083 if (opt .embed_crc_delimiter == 0 ) opt .embed_crc_delimiter = " " ;
10741084}
0 commit comments