473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

multibyte length

Is there a function to find the length, in wide characters, of a
multibyte string?
Mar 3 '06 #1
3 2431
Jordan Abel <ra*******@gmail.com> writes:
Is there a function to find the length, in wide characters, of a
multibyte string?


<OT>
If you have the POSIX version of mbstowcs, you can pass it a NULL
first argument to get this number.
</OT>

If you limit yourself to Standard C, I think you have to actually
perform the conversion, and then find out with wcslen().
Mar 3 '06 #2
On 2006-03-03, Micah Cowan <mi***@cowan.name> wrote:
Jordan Abel <ra*******@gmail.com> writes:
Is there a function to find the length, in wide characters, of a
multibyte string?
<OT>
If you have the POSIX version of mbstowcs, you can pass it a NULL
first argument to get this number.


Given that this came up when i was trying to answer someone's question
in c.u.p, this is relevant, thanks.
</OT>

If you limit yourself to Standard C, I think you have to actually
perform the conversion, and then find out with wcslen().


The reason for this was to be able to perform the conversion into memory
that is from malloc while calling malloc only once. in order to make a
wide copy of argv to pass to a "wmain"
Mar 3 '06 #3
Jordan Abel <ra*******@gmail.com> writes:
On 2006-03-03, Micah Cowan <mi***@cowan.name> wrote:
Jordan Abel <ra*******@gmail.com> writes:
Is there a function to find the length, in wide characters, of a
multibyte string?


<OT>
If you have the POSIX version of mbstowcs, you can pass it a NULL
first argument to get this number.


Given that this came up when i was trying to answer someone's question
in c.u.p, this is relevant, thanks.
</OT>

If you limit yourself to Standard C, I think you have to actually
perform the conversion, and then find out with wcslen().


The reason for this was to be able to perform the conversion into memory
that is from malloc while calling malloc only once. in order to make a
wide copy of argv to pass to a "wmain"


Makes sense to me: snprintf() allows this. It's beyond me why Standard
C neglected to provide such a thing in the first place. I kind of hope
that future versions will add the POSIX behavior, as it's very useful,
and certainly not hard to implement.
Mar 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: lian | last post by:
Hi all, I want to write some UTF-8 Chinese characters to file with following php codes: <code> ....... $fp = fopen($filepath,'wb'); fwrite($fp,$utf8string,strlen($utf8string)); fclose($fp);...
18
by: Zygmunt Krynicki | last post by:
Hello I've browsed the FAQ but apparently it lacks any questions concenring wide character strings. I'd like to calculate the length of a multibyte string without converting the whole string. ...
3
by: yazan jab | last post by:
Is it true that Multibyte characters are : char arrays (witch represent a string from the basic characters set). In this case Wide characters are the way for encoding characters from the...
2
by: groups | last post by:
I have a C# application which needs to convert MultiByte strings to Unicode. However, I cannot get MultiByteToWideChar to behave as expected within ..net. I have declared it as follows: ...
3
by: Weiping | last post by:
Hi, while upgrade to 8.0 (beta3) we got some problem: we have a database which encoding is UNICODE, when we do queries like: select upper('ÖÐÎÄ'); --select some multibyte character, then...
1
by: Marcel Ruff | last post by:
Hi, i have the question on how to determine the string length of a wide string and a multibyte string: 1. Number of letters (one letter may use three bytes) 2. Number of bytes In the code...
0
by: Munch | last post by:
my C program deals with single byte characters but now i want to fetch multibyte data stored in the datbase so what all changes i need to make to the code so that it handles multibyte data as well....
10
by: Dancefire | last post by:
Hi, everyone, I'm writing a program using wstring(wchar_t) as internal string. The problem is raised when I convert the multibyte char set string with different encoding to wstring(which is...
1
johny10151981
by: johny10151981 | last post by:
Hello Everybody, I am having a problem with converting value from multibyte to widechar input variable is data output variable is data_m #define CP_SHIFT_JIS 932
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.