X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Mime-Version: 1.0 (Apple Message framework v752.3) Content-Transfer-Encoding: 7bit Message-Id: Content-Type: text/plain; charset=US-ASCII; format=flowed To: cygwin AT cygwin DOT com From: Christoph Ender Subject: No space calculation in wcstombs? Date: Tue, 23 Oct 2007 11:52:01 +0200 X-Mailer: Apple Mail (2.752.3) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Hi all, when converting wchar_t*- to (mb)char*-Strings I've been so far using the wcstombs function in two steps: One call to length=wcstombs(NULL, *src, 0) in order to make the function return the space required for the dest string and one call wo wcstombs(*dest, *src, length) to actually convert the src string after allocating (length) bytes. I've just noticed that the first step does not work with cygwin and I've attached a small example to demonstrate the problem. On a Linux- and Mac OS X-machine the return value is 26, on cygwin 0. Since wcstombs is supposed to be affected by the current locale setting I've set the locale to "C", but the result is still the same: cygwin always tries to do the actual converion (if the len parameter is not 0 there is a segfault) instead of measuring the space requirements. ----------8<----------8<----------8<----------8<---------- #include #include #include int main(int argc, char *argv[]) { int result; wchar_t s[] = L"abcdefghijklmnopqrstuvwxyz"; printf("Locale: %s\n", setlocale(LC_ALL, "C")); result = wcstombs(NULL, s, 0); printf("Required space: %d.\n", result); return 0; } ----------8<----------8<----------8<----------8<---------- What am I doing wrong here? Or is this actually a cygwin problem? Thanks in advance, Christoph. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/