# HG changeset patch
# Node ID 20641156d20fdd8f21b8c4cd173594add100fd1a
# Parent  2c46eaff49b1ebe8288a8df5821c02c7286c21f2
diff --git a/birb/birbstr.h b/birb/birbstr.h
new file mode 100644
--- /dev/null
+++ b/birb/birbstr.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2023-2025 Birb Developers
+ *
+ * Birb is the legal property of its developers, whose names are too
+ * numerous to list here. Please refer to the AUTHORS file distributed
+ * with this source distribution
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#if !defined(BIRB_GLOBAL_HEADER_INSIDE) && !defined(BIRB_COMPILATION)
+# error "only <birb.h> may be included directly"
+#endif
+
+#ifndef BIRB_STR_H
+#define BIRB_STR_H
+
+#include <glib.h>
+
+#include "birbversion.h"
+
+G_BEGIN_DECLS
+
+/**
+ * birb_str_is_empty:
+ * @str: (nullable): the string to check
+ *
+ * Determines if @str is empty or not.
+ *
+ * Returns: true if @str is empty; false otherwise.
+ *
+ * Since: 0.4
+ */
+BIRB_AVAILABLE_STATIC_INLINE_IN_0_4
+static inline gboolean
+birb_str_is_empty(const char *str) {
+	return (str == NULL || str[0] == '\0');
+}
+
+/**
+ * birb_str_equal:
+ * @str1: (nullable): the first string
+ * @str2: (nullable): the second string
+ *
+ * Checks if @str1 is equal to @str2.
+ *
+ * Returns: true if the strings are equal; false otherwise.
+ *
+ * Since: 0.4
+ */
+BIRB_AVAILABLE_STATIC_INLINE_IN_0_4
+static inline gboolean
+birb_str_equal(const char *str1, const char *str2) {
+	return (g_strcmp0(str1, str2) == 0);
+}
+
+/**
+ * birb_str_to_uint:
+ * @str: (nullable): a string to convert to an unsigned integer
+ *
+ * Converts @str to an unsigned integer.
+ *
+ * Returns: The converted value or 0 on error.
+ *
+ * Since: 0.4
+ */
+BIRB_AVAILABLE_STATIC_INLINE_IN_0_4
+static inline guint
+birb_str_to_uint(const char *str) {
+	int ivalue;
+
+	if(birb_str_is_empty(str)) {
+		return 0;
+	}
+
+	ivalue = atoi(str);
+
+	return (guint)ivalue;
+}
+
+G_END_DECLS
+
+#endif /* BIRB_STR_H */
diff --git a/birb/meson.build b/birb/meson.build
--- a/birb/meson.build
+++ b/birb/meson.build
@@ -19,6 +19,7 @@
   'birbenv.h',
   'birbfilter.h',
   'birbqueuedoutputstream.h',
+  'birbstr.h',
   'birbstringobject.h',
   'birbversion.h',
 ]
diff --git a/birb/tests/meson.build b/birb/tests/meson.build
--- a/birb/tests/meson.build
+++ b/birb/tests/meson.build
@@ -5,6 +5,7 @@
   'env',
   'filter',
   'queued_output_stream',
+  'str',
   'string_object',
 ]
 
diff --git a/birb/tests/test_str.c b/birb/tests/test_str.c
new file mode 100644
--- /dev/null
+++ b/birb/tests/test_str.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2023-2025 Birb Developers
+ *
+ * Birb is the legal property of its developers, whose names are too
+ * numerous to list here. Please refer to the AUTHORS file distributed
+ * with this source distribution
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include <birb.h>
+
+/******************************************************************************
+ * Tests
+ *****************************************************************************/
+static void
+test_birb_str_is_empty(void) {
+	g_assert_true(birb_str_is_empty(NULL));
+	g_assert_true(birb_str_is_empty(""));
+
+	g_assert_false(birb_str_is_empty("birb"));
+}
+
+static void
+test_birb_str_equal(void) {
+	g_assert_true(birb_str_equal(NULL, NULL));
+	g_assert_true(birb_str_equal("", ""));
+	g_assert_true(birb_str_equal("birb", "birb"));
+
+	g_assert_false(birb_str_equal(NULL, "birb"));
+	g_assert_false(birb_str_equal("birb", NULL));
+}
+
+static void
+test_birb_str_to_uint(void) {
+	g_assert_cmpuint(birb_str_to_uint(NULL), ==, 0);
+	g_assert_cmpuint(birb_str_to_uint(""), ==, 0);
+	g_assert_cmpuint(birb_str_to_uint("10"), ==, 10);
+	g_assert_cmpuint(birb_str_to_uint("birb"), ==, 0);
+	g_assert_cmpuint(birb_str_to_uint("3.14"), ==, 3);
+}
+
+/******************************************************************************
+ * Main
+ *****************************************************************************/
+int
+main(int argc, char *argv[]) {
+	g_test_init(&argc, &argv, NULL);
+
+	g_test_add_func("/birb/str/is-empty", test_birb_str_is_empty);
+	g_test_add_func("/birb/str/equal", test_birb_str_equal);
+	g_test_add_func("/birb/str/to-uint", test_birb_str_to_uint);
+
+	return g_test_run();
+}
