static void ThrowIfInvalidTrimmingDelimiter(HSTRING value) { // The delimiter must be a single code point and so cannot be more than // 2 UTF-16 code units long if (WindowsGetStringLen(value) > 2) ThrowHR(E_INVALIDARG); }
/*********************************************************************** * WindowsSubstringWithSpecifiedLength (combase.@) */ HRESULT WINAPI WindowsSubstringWithSpecifiedLength(HSTRING str, UINT32 start, UINT32 len, HSTRING *out) { struct hstring_private *priv = impl_from_HSTRING(str); TRACE("(%p, %u, %u, %p)\n", str, start, len, out); if (out == NULL) return E_INVALIDARG; if (start + len < start || start + len > WindowsGetStringLen(str)) return E_BOUNDS; if (len == 0) { *out = NULL; return S_OK; } return WindowsCreateString(&priv->buffer[start], len, out); }
/*********************************************************************** * WindowsSubstring (combase.@) */ HRESULT WINAPI WindowsSubstring(HSTRING str, UINT32 start, HSTRING *out) { struct hstring_private *priv = impl_from_HSTRING(str); UINT32 len = WindowsGetStringLen(str); TRACE("(%p, %u, %p)\n", str, start, out); if (out == NULL) return E_INVALIDARG; if (start > len) return E_BOUNDS; if (start == len) { *out = NULL; return S_OK; } return WindowsCreateString(&priv->buffer[start], len - start, out); }