1*fa9bb8cfSjmc.\" $OpenBSD: wcscpy.3,v 1.5 2016/11/12 08:58:43 jmc Exp $ 28c40de08Sschwarze.\" 37042370eSnicm.\" Copyright (c) 1990, 1991 The Regents of the University of California. 47042370eSnicm.\" All rights reserved. 57042370eSnicm.\" 67042370eSnicm.\" This code is derived from software contributed to Berkeley by 77042370eSnicm.\" Chris Torek and the American National Standards Committee X3, 87042370eSnicm.\" on Information Processing Systems. 97042370eSnicm.\" 107042370eSnicm.\" Redistribution and use in source and binary forms, with or without 117042370eSnicm.\" modification, are permitted provided that the following conditions 127042370eSnicm.\" are met: 137042370eSnicm.\" 1. Redistributions of source code must retain the above copyright 147042370eSnicm.\" notice, this list of conditions and the following disclaimer. 157042370eSnicm.\" 2. Redistributions in binary form must reproduce the above copyright 167042370eSnicm.\" notice, this list of conditions and the following disclaimer in the 177042370eSnicm.\" documentation and/or other materials provided with the distribution. 187042370eSnicm.\" 3. Neither the name of the University nor the names of its contributors 197042370eSnicm.\" may be used to endorse or promote products derived from this software 207042370eSnicm.\" without specific prior written permission. 217042370eSnicm.\" 227042370eSnicm.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 237042370eSnicm.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 247042370eSnicm.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 257042370eSnicm.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 267042370eSnicm.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 277042370eSnicm.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 287042370eSnicm.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 297042370eSnicm.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 307042370eSnicm.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 317042370eSnicm.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 327042370eSnicm.\" SUCH DAMAGE. 337042370eSnicm.\" 34*fa9bb8cfSjmc.Dd $Mdocdate: November 12 2016 $ 357042370eSnicm.Dt WCSCPY 3 367042370eSnicm.Os 377042370eSnicm.Sh NAME 387042370eSnicm.Nm wcscpy , 397042370eSnicm.Nm wcsncpy 407042370eSnicm.Nd copy wide strings 417042370eSnicm.Sh SYNOPSIS 4264d4e987Stedu.In wchar.h 437042370eSnicm.Ft wchar_t * 447042370eSnicm.Fn wcscpy "wchar_t * restrict dst" "const wchar_t * restrict src" 457042370eSnicm.Ft wchar_t * 467042370eSnicm.Fo wcsncpy 477042370eSnicm.Fa "wchar_t * restrict dst" 487042370eSnicm.Fa "const wchar_t * restrict src" 497042370eSnicm.Fa "size_t len" 507042370eSnicm.Fc 517042370eSnicm.Sh DESCRIPTION 527042370eSnicmThe 537042370eSnicm.Fn wcscpy 548c40de08Sschwarzeand 558c40de08Sschwarze.Fn wcsncpy 568c40de08Sschwarzefunctions copy the wide string 577042370eSnicm.Fa src 587042370eSnicmto 597042370eSnicm.Fa dst 607042370eSnicm(including the terminating null wide character). 617042370eSnicm.Pp 627042370eSnicmThe 637042370eSnicm.Fn wcsncpy 647042370eSnicmfunction copies not more than 657042370eSnicm.Fa len 667042370eSnicmwide characters to 677042370eSnicm.Fa dst , 687042370eSnicmappending null wide characters if the length of 697042370eSnicm.Fa src 707042370eSnicmis less than 717042370eSnicm.Fa len , 727042370eSnicmand 737042370eSnicm.Em not 747042370eSnicmterminating 757042370eSnicm.Fa dst 767042370eSnicmif the length of 777042370eSnicm.Fa src 787042370eSnicmis greater than or equal to 797042370eSnicm.Fa len . 80e6e4f203Smillert.Pp 81e6e4f203SmillertIf the 82e6e4f203Smillert.Fa src 83e6e4f203Smillertand 84e6e4f203Smillert.Fa dst 85e6e4f203Smillertstrings overlap, the behavior is undefined. 867042370eSnicm.Sh RETURN VALUES 877042370eSnicmThe 887042370eSnicm.Fn wcscpy 897042370eSnicmand 907042370eSnicm.Fn wcsncpy 917042370eSnicmfunctions return 927042370eSnicm.Fa dst . 937042370eSnicm.Sh SEE ALSO 948c40de08Sschwarze.Xr strcpy 3 , 958c40de08Sschwarze.Xr strlcpy 3 , 968c40de08Sschwarze.Xr wcscat 3 , 977042370eSnicm.Xr wcslcpy 3 , 987042370eSnicm.Xr wmemcpy 3 , 997042370eSnicm.Xr wmemmove 3 1007042370eSnicm.Sh STANDARDS 1017042370eSnicmThe 1027042370eSnicm.Fn wcscpy 1037042370eSnicmand 1047042370eSnicm.Fn wcsncpy 1057042370eSnicmfunctions conform to 1067042370eSnicm.St -isoC-99 1077042370eSnicmand were first introduced in 1087042370eSnicm.St -isoC-amd1 . 1098c40de08Sschwarze.Sh HISTORY 1108c40de08SschwarzeThe 1118c40de08Sschwarze.Fn wcscpy 1128c40de08Sschwarzeand 1138c40de08Sschwarze.Fn wcsncpy 1148c40de08Sschwarzefunctions were ported from 1158c40de08Sschwarze.Nx 1168c40de08Sschwarzeand first appeared in 1178c40de08Sschwarze.Ox 3.8 . 1188c40de08Sschwarze.Sh CAVEATS 1198c40de08SschwarzeUsing the functions 1208c40de08Sschwarze.Fn wcscpy 1218c40de08Sschwarzeand 1228c40de08Sschwarze.Fn wcsncpy 1238c40de08Sschwarzeis very error-prone with respect to buffer overflows; 1248c40de08Sschwarzesee the EXAMPLES section in 125*fa9bb8cfSjmc.Xr strncpy 3 1268c40de08Sschwarzefor correct usage. 1278c40de08SschwarzeUsing 1288c40de08Sschwarze.Xr wcslcpy 3 1298c40de08Sschwarzeis a better choice in most cases. 130