[Github-comments] [geany/geany] Provide utf-8 command line arguments on Windows (#1258)

Matthew Brush notifications at xxxxx
Wed Nov 9 11:22:56 UTC 2016


codebrainz commented on this pull request.



> @@ -1032,4 +1032,31 @@ gchar *win32_get_user_config_dir(void)
 	return g_build_filename(g_get_user_config_dir(), "geany", NULL);
 }
 
+
+void win32_make_argc_and_argv_in_utf8(gint *pargc, gchar ***pargv)
+{
+	int num_arg;
+	LPWSTR *szarglist = CommandLineToArgvW(GetCommandLineW(), &num_arg);
+	char **utf8argv = g_new0(char *, num_arg + 1);
+	int i = num_arg;
+	while(i)
+	{
+		i--;
+		utf8argv[i] = g_utf16_to_utf8((gunichar2 *)szarglist[i], -1, NULL, NULL, NULL);

IMO, it would be cleaner if it didn't hardcode UTF-16 assumptions. While it's highly unlikely to change any time soon, Win32 does provide functions to convert to/from various encodings to its native "wide" encoding without hard-coding what that is.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/1258
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20161109/2fefbf8e/attachment.html>


More information about the Github-comments mailing list