aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil/unicode-utils.c
AgeCommit message (Collapse)AuthorFilesLines
2023-09-24Convert wsutil to C99 typesGerald Combs1-12/+12
Ping #19116
2023-02-08Replace g_utf8_make_valid() with own functionJoão Valverde1-3/+10
The function ws_utf8_make_valid() is all-around better and also does maximal substitution of subparts.
2023-02-06Convert unicode-utils.[ch] to 4-space indentationJoão Valverde1-91/+87
2023-02-06Move get_utf_8_string() to wsutilJoão Valverde1-0/+187
2022-10-14wsutil: Rewrite ws_utf8_char_len() using a lookup tableJoão Valverde1-12/+18
Rewrite for speed and correctness. This implementation is more strict with invalid first bytes (continuation bytes, invalid codepoints and some overlong sequences). Returns 0 instead of -1 for invalid bytes.
2021-12-19wsutil: Use snprintf() and ws_strdup_printf()João Valverde1-2/+2
Replace GLib I/O with C library I/O.
2021-06-10wsutil: argv[] is a NULL terminated arrayJoão Valverde1-1/+2
2019-07-26HTTPS (almost) everywhere.Guy Harris1-1/+1
Change all wireshark.org URLs to use https. Fix some broken links while we're at it. Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c Reviewed-on: https://code.wireshark.org/review/34089 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-10-08Bring back arg_list_utf_16to8(), but have it just do UTF-16-to-UTF-8 mapping.Guy Harris1-0/+14
Call it from wmain() in the command-line tools, passing it the input argument count and vector, and call it from main() in Wireshark, after getting a UTF-16 argument vector from passing the result of GetCommandLineW() to CommandLineToArgvW(). Change-Id: I0e51703c0a6c92f7892d196e700ab437bd702514 Reviewed-on: https://code.wireshark.org/review/30063 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-10-07Use wsetargv.obj, and wmain() rather than main(), on Windows.Guy Harris1-18/+0
Doing so for command-line programs means that the argument list doesn't ever get converted to the local code page; converting to the local code page can mangle file names that *can't* be converted to the local code page. Furthermore, code that uses setargv.obj rather than wsetargv.obj has issues in some versions of Windows 10; see bug 15151. That means that converting the argument list to UTF-8 is a bit simpler - we don't need to call GetCommandLineW() or CommandLineToArgvW(), we just loop over the UTF-16LE argument strings in argv[]. While we're at it, note in Wireshark's main() why we discard argv on Windows (Qt does the same "convert-to-the-local-code-page" stuff); that means we *do* need to call GetCommandLineW() and CommandLineToArgvW() in main() (i.e., we duplicate what Qt's WinMain() does, but converting to UTF-8 rather than to the local code page). Change-Id: I35b57c1b658fb3e9b0c685097afe324e9fe98649 Ping-Bug: 15151 Reviewed-on: https://code.wireshark.org/review/30051 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-28Include <config.h> so UNICODE is defined.Guy Harris1-0/+2
All other files should do so; this file should, so that we're using the Unicode versions of Windows APIs (especially given that other files that include wsutil/unicode-utils.h will be doing so and expecting UTF-16 strings from utf_8to16_snprintf()). Change-Id: I7eccf580ab0dc504aa78b345e36e2fcda818a7c5 Reviewed-on: https://code.wireshark.org/review/26170 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-08replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.Dario Lombardo1-1/+1
The first is deprecated, as per https://spdx.org/licenses/. Change-Id: I8e21e1d32d09b8b94b93a2dc9fbdde5ffeba6bed Reviewed-on: https://code.wireshark.org/review/25661 Petri-Dish: Anders Broman <a.broman58@gmail.com> Petri-Dish: Dario Lombardo <lomato@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-12-10Convert to using use SPDX identifier on wsutil directoryMichael Mann1-13/+1
Change-Id: Id73e641499e75bc1afc1dea29682418156f461fe Reviewed-on: https://code.wireshark.org/review/24751 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-04-28Win32: Pass a mutable string to CreateProcess.Gerald Combs1-1/+1
CreateProcess can modify its second (lpCommandLine) argument. Don't pass it the output of utf_8to16. Constify the return value of utf_8to16. Change-Id: I0d4361396e90c88a4ab2a3f2f0e058230e897fdf Reviewed-on: https://code.wireshark.org/review/15155 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-06-17Qt: fix a crash when closing application under WindowsPascal Quantin1-0/+1
QCoreApplication visits eldritch horrors upon argv on Windows. Keep a local copy for our own processing. --- [ Pascal's original comments ] g6c4ec4a introduced the use of arg_list_utf_16to8 that triggers a crash on my computer when freeing the g_allocated memory. Let's do a similar work but with a memory allocator that does not trigger an exception. Also fix a memory leak in arg_list_utf_16to8 while we are at it. Change-Id: I93d899af20b09c9a5d584a46297f715591502df9 Reviewed-on: https://code.wireshark.org/review/8961 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Gerald Combs <gerald@wireshark.org> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-14Add editor-modelines; adjust whitespace.Bill Meier1-7/+20
Change-Id: I8cad872cee972a6d22a72852dac57fd188daca84 Reviewed-on: https://code.wireshark.org/review/4683 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-03-04Remove all $Id$ from top of fileAlexis La Goutte1-2/+0
(Using sed : sed -i '/^ \* \$Id\$/,+1 d') Fix manually some typo (in export_object_dicom.c and crc16-plain.c) Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8 Reviewed-on: https://code.wireshark.org/review/497 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-01-08Need <strsafe.h> for StringCchPrintf().Guy Harris1-0/+1
svn path=/trunk/; revision=54644
2014-01-07As checkAPIs.pl says, "use StringCchPrintf".Guy Harris1-1/+1
svn path=/trunk/; revision=54641
2014-01-07Fix bug #9618: Invalid utf8 causes JSON dissector assertion failure ↵Jakub Zawadzki1-4/+17
"g_utf8_validate" Validate JSON UTF-8 characters, replace with '?' when invalid. svn path=/trunk/; revision=54633
2012-06-28Update Free Software Foundation address.Jakub Zawadzki1-1/+1
(COPYING will be updated in next commit) svn path=/trunk/; revision=43536
2011-05-24Move the Windows argument list conversion code to a common routine.Gerald Combs1-0/+16
svn path=/trunk/; revision=37372
2010-12-07Move getenv_utf8() to wsutil.Jeff Morriss1-3/+9
svn path=/trunk/; revision=35148
2009-08-31Add utf_8to16_snprintf() which creates a UTF16 string according to the given ↵Kovarththanan Rajaratnam1-5/+13
format string. The format string + arguments are expected to be in UTF-8 format. This change effectively removes the only place where we use PRIu64. svn path=/trunk/; revision=29635
2008-07-11unicode-utils.c is only for Windows; don't build it on UN*X. Put in a checkJeff Morriss1-2/+3
to cause it to fail when built on UN*X. svn path=/trunk/; revision=25704
2008-06-30Move privileges.c and unicode-utils.c from epan to wsutil (so things likeJeff Morriss1-0/+128
capinfos and dumpcap don't need to depend on libwireshark nor directly pull in those modules). Because capinfos and editcap were only being linked with privileges.c if we had plugins, this allows those programs to be linked when someone is compiling --without-plugins. svn path=/trunk/; revision=25640