split out the json string-to-int functions for general use

PiperOrigin-RevId: 469509635
diff --git a/BUILD b/BUILD
index bd93ff4..a49327b 100644
--- a/BUILD
+++ b/BUILD
@@ -432,6 +432,7 @@
     copts = UPB_DEFAULT_COPTS,
     visibility = ["//visibility:public"],
     deps = [
+        ":atoi_internal",
         ":encode_internal",
         ":port",
         ":reflection",
@@ -590,6 +591,17 @@
 )
 
 cc_test(
+    name = "atoi_test",
+    srcs = ["upb/internal/atoi_test.cc"],
+    copts = UPB_DEFAULT_CPPOPTS,
+    deps = [
+        ":atoi_internal",
+        "@com_google_absl//absl/strings",
+        "@com_google_googletest//:gtest_main",
+    ],
+)
+
+cc_test(
     name = "test_cpp",
     srcs = ["upb/test_cpp.cc"],
     copts = UPB_DEFAULT_CPPOPTS,
@@ -769,6 +781,15 @@
 )
 
 cc_library(
+    name = "atoi_internal",
+    srcs = ["upb/internal/atoi.c"],
+    hdrs = ["upb/internal/atoi.h"],
+    copts = UPB_DEFAULT_COPTS,
+    visibility = ["//:__subpackages__"],
+    deps = [":port"],
+)
+
+cc_library(
     name = "decode_internal",
     srcs = [
         "upb/decode.h",
@@ -839,6 +860,7 @@
     libs = [
         ":arena_internal",
         ":array_internal",
+        ":atoi_internal",
         ":collections",
         ":decode_internal",
         ":descriptor_upb_proto",
@@ -870,6 +892,7 @@
     libs = [
         ":arena_internal",
         ":array_internal",
+        ":atoi_internal",
         ":collections",
         ":decode_internal",
         ":descriptor_upb_proto",
@@ -904,6 +927,7 @@
     libs = [
         ":arena_internal",
         ":array_internal",
+        ":atoi_internal",
         ":collections",
         ":decode_internal",
         ":descriptor_upb_proto",