summaryrefslogtreecommitdiff
path: root/src/corefx/System.Globalization.Native/errors.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corefx/System.Globalization.Native/errors.h')
-rw-r--r--src/corefx/System.Globalization.Native/errors.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/corefx/System.Globalization.Native/errors.h b/src/corefx/System.Globalization.Native/errors.h
new file mode 100644
index 0000000000..2bfbdb2ba1
--- /dev/null
+++ b/src/corefx/System.Globalization.Native/errors.h
@@ -0,0 +1,36 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+#pragma once
+
+#include <unicode/utypes.h>
+
+/*
+* These values should be kept in sync with
+* Interop.GlobalizationInterop.ResultCode
+*/
+enum ResultCode : int32_t
+{
+ Success = 0,
+ UnknownError = 1,
+ InsufficentBuffer = 2,
+};
+
+/*
+Converts a UErrorCode to a ResultCode.
+*/
+static ResultCode GetResultCode(UErrorCode err)
+{
+ if (err == U_BUFFER_OVERFLOW_ERROR || err == U_STRING_NOT_TERMINATED_WARNING)
+ {
+ return InsufficentBuffer;
+ }
+
+ if (U_SUCCESS(err))
+ {
+ return Success;
+ }
+
+ return UnknownError;
+}