RTUtf16NLenEx.cpp revision 13493ab7596e827b8d0caab2c89e635dd65f78f9
430474e5ec398f769830a548d818d75ff37d5113vboxsync/* $Id$ */
430474e5ec398f769830a548d818d75ff37d5113vboxsync/** @file
459e93059a8be95d20eda3d1dad52187595a688cvboxsync * IPRT - RTUtf16NLenEx.
459e93059a8be95d20eda3d1dad52187595a688cvboxsync */
430474e5ec398f769830a548d818d75ff37d5113vboxsync
430474e5ec398f769830a548d818d75ff37d5113vboxsync/*
459e93059a8be95d20eda3d1dad52187595a688cvboxsync * Copyright (C) 2008-2014 Oracle Corporation
459e93059a8be95d20eda3d1dad52187595a688cvboxsync *
459e93059a8be95d20eda3d1dad52187595a688cvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
459e93059a8be95d20eda3d1dad52187595a688cvboxsync * available from http://www.virtualbox.org. This file is free software;
459e93059a8be95d20eda3d1dad52187595a688cvboxsync * you can redistribute it and/or modify it under the terms of the GNU
459e93059a8be95d20eda3d1dad52187595a688cvboxsync * General Public License (GPL) as published by the Free Software
459e93059a8be95d20eda3d1dad52187595a688cvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
459e93059a8be95d20eda3d1dad52187595a688cvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
459e93059a8be95d20eda3d1dad52187595a688cvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
430474e5ec398f769830a548d818d75ff37d5113vboxsync *
430474e5ec398f769830a548d818d75ff37d5113vboxsync * The contents of this file may alternatively be used under the terms
459e93059a8be95d20eda3d1dad52187595a688cvboxsync * of the Common Development and Distribution License Version 1.0
430474e5ec398f769830a548d818d75ff37d5113vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
459e93059a8be95d20eda3d1dad52187595a688cvboxsync * VirtualBox OSE distribution, in which case the provisions of the
459e93059a8be95d20eda3d1dad52187595a688cvboxsync * CDDL are applicable instead of those of the GPL.
459e93059a8be95d20eda3d1dad52187595a688cvboxsync *
459e93059a8be95d20eda3d1dad52187595a688cvboxsync * You may elect to license modified versions of this file under the
459e93059a8be95d20eda3d1dad52187595a688cvboxsync * terms and conditions of either the GPL or the CDDL or both.
459e93059a8be95d20eda3d1dad52187595a688cvboxsync */
459e93059a8be95d20eda3d1dad52187595a688cvboxsync
459e93059a8be95d20eda3d1dad52187595a688cvboxsync/*******************************************************************************
459e93059a8be95d20eda3d1dad52187595a688cvboxsync* Header Files *
459e93059a8be95d20eda3d1dad52187595a688cvboxsync*******************************************************************************/
459e93059a8be95d20eda3d1dad52187595a688cvboxsync#include <iprt/string.h>
459e93059a8be95d20eda3d1dad52187595a688cvboxsync#include "internal/iprt.h"
459e93059a8be95d20eda3d1dad52187595a688cvboxsync
459e93059a8be95d20eda3d1dad52187595a688cvboxsync
459e93059a8be95d20eda3d1dad52187595a688cvboxsyncRTDECL(int) RTUtf16NLenEx(PCRTUTF16 pwszString, size_t cwcMax, size_t *pcwc)
459e93059a8be95d20eda3d1dad52187595a688cvboxsync{
459e93059a8be95d20eda3d1dad52187595a688cvboxsync PCRTUTF16 pwcEnd = RTUtf16End(pwszString, cwcMax);
459e93059a8be95d20eda3d1dad52187595a688cvboxsync if (!pwcEnd)
459e93059a8be95d20eda3d1dad52187595a688cvboxsync {
459e93059a8be95d20eda3d1dad52187595a688cvboxsync *pcwc = cwcMax;
459e93059a8be95d20eda3d1dad52187595a688cvboxsync return VERR_BUFFER_OVERFLOW;
459e93059a8be95d20eda3d1dad52187595a688cvboxsync }
459e93059a8be95d20eda3d1dad52187595a688cvboxsync *pcwc = pwcEnd - pwszString;
459e93059a8be95d20eda3d1dad52187595a688cvboxsync return VINF_SUCCESS;
459e93059a8be95d20eda3d1dad52187595a688cvboxsync}
459e93059a8be95d20eda3d1dad52187595a688cvboxsyncRT_EXPORT_SYMBOL(RTUtf16NLenEx);
459e93059a8be95d20eda3d1dad52187595a688cvboxsync
459e93059a8be95d20eda3d1dad52187595a688cvboxsync