🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #11451

Re: conversion problem

#11451
From: Remy Lebeau (TeamB)
Date: Thu, 12 Feb 2004 07:28
27 lines
1691 bytes
"Martin C" <martinc@aol.com> wrote in message
news:402b01e2$1@newsgroups.borland.com...

> I need to convert from AnsiString to WCHAR

The easiest way is to simply assign the AnsiString to a WideString:

    AnsiString TextNo1 = "1234567890";
    WideString abc = TextNo1;

> so I am using the following code but I always get AV

WideChar() expects an allocated buffer, but you are passing it both an
uninitialized pointer and an incorrect buffer size.  If you must use the
WideChar() method then you need to use AnsiString's WideCharBufSize() method
as well, ie:

    AnsiString TextNo1 = "1234567890";
    int size = TextNo1.WideCharBufSize();
    WCHAR *abc = new WCHAR[size];
    TextNo1.WideChar(abc, size);
    //...
    delete[] abc;


Gambit
Technical Details
Message-ID: <402b2964$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <402b01e2$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,ed7097c9ad2bbcef
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-02-11 23:39:23 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <402b01e2$1@newsgroups.borland.com>
Subject: Re: conversion problem
Date: Wed, 11 Feb 2004 23:28:44 -0800
Lines: 29
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 67.22.138.253
Message-ID: <402b2964$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1076570468 67.22.138.253 (11 Feb 2004 23:21:08 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail