[PATCH BlueZ 1/3] shared/util: implement argsisutf8()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This implements argsisutf8() which checks that all strings in the
argv array are written in utf8.
---
 src/shared/util.c | 12 ++++++++++++
 src/shared/util.h |  1 +
 2 files changed, 13 insertions(+)

diff --git a/src/shared/util.c b/src/shared/util.c
index 6e7634ad1..5d3a14d96 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -1947,3 +1947,15 @@ bool strisutf8(const char *str, size_t len)
 
 	return true;
 }
+
+bool argsisutf8(int argc, char *argv[])
+{
+	for (int i = 0; i < argc; i++) {
+		if (!strisutf8(argv[i], strlen(argv[i]))) {
+			printf("Invalid character in string: %s\n", argv[i]);
+			return false;
+		}
+	}
+
+	return true;
+}
diff --git a/src/shared/util.h b/src/shared/util.h
index f2ca4f29f..dd357fb93 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -91,6 +91,7 @@ char *strdelimit(char *str, char *del, char c);
 int strsuffix(const char *str, const char *suffix);
 char *strstrip(char *str);
 bool strisutf8(const char *str, size_t length);
+bool argsisutf8(int argc, char *argv[]);
 
 void *util_malloc(size_t size);
 void *util_memdup(const void *src, size_t size);
-- 
2.34.1





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux