|
Hi all,
I have a very important problem. that How to judge a string encoding is euc, sjis, ascii or others?
I must alway kown a string encoder, and I must convert it to other encoder.
so first, I must know the encoder of a string.
thank you very much.
thanks a lot.
---------------------------
Vc++.net Managed
|
|
|
|
|
a function that judge a string is ASCII or EUC, SJIS, JIS was welcome.
thanks.
----Junyin.Wu
|
|
|
|
|
there is no way to know such an information programatically... sorry
there is only one thing you can know : if the length of the string have an odd number of bytes, it cannot be UNICODE
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
try IMultiLanguage2::DetectCodepageInIStream
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
http://bloglines.com/public/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
thank you very much,
and we are trying.....
|
|
|
|
|
Of course it can be Unicode with an odd number of bytes. In Unicode text encoded with UTF-8, the characters are composed of byte sequences of sizes between 1 and 4 bytes, depending on the character. Perhaps you meant UTF-16 or UTF-32?
--
The Blog: Bits and Pieces
-- modified at 1:40 Tuesday 1st November, 2005
|
|
|
|
|
|
Hi,
Being relatively new to socket programming, I need some assistance in sending and receiving data over a TCP connected socket. I'm familiar with using send and recv commands to send and recv buffered character data, but what about if I want to send and recv data formatted within a structure? For example,
<code>
main ()
{
struct {
int data1;
double data2;
bool indicator;
}msg;
// initialize data
msg.data1 = 0;
msg.data2 = 5.8;
msg.inidicator = false;
// send data
.....
// receive data
.....
}
</code>
Are the send and recv commands the right ones to use for this type of information to send and receive data over a TCP connected socket or are there other commands that are better suited for this. When I use the send(socketfd, (char *)&msg, 0), it "appears" to work, but when receiving the data using recv(socketfd, (char *)&msg, 0), it returns with a -1.
Thanks in advance for any help.
-Martin
NB: The commands must work on both the Windows and UNIX side, so Windows specific commands wouldn't work.
|
|
|
|
|
you are sending 0 bytes. you need to give it a size that your are sending. You also need to give a size when you recv.
It would work best if you just used sizeof(msg)
|
|
|
|
|
just check out the following code:
<br />
main()<br />
{<br />
int a=32;<br />
int b=0x20;<br />
printf("%d %d",a,b);<br />
getch();<br />
}<br />
the o/p of this code as expected would be -->32 32 now my question is that if i want the o/p to be like this-->32 0x20 what should i do.i am open to suggestions in C++ also.
plz ans asap.
thank you.
bye
That is a good way of doing difficult thing easily sir but i dont want to use specifier. i want to use the method of sepration which is used by compiler itself. try to differentiate between the two using functions atoi()
and itoa().
however thank you for your time sir and plz pardon me for my english
amsbali@yahoo.co.in
-- modified at 7:49 Sunday 30th October, 2005
|
|
|
|
|
just change your format string :
printf("%d %#X", a, b);
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
that is a good way of doing difficult thing easily sir but i dont want to use specifier. i want to use the method of sepration which is used by compiler itself. try to differentiate between the two using functions atoi()
and itoa().
however thank you for your time sir and plz pardon me for my english
|
|
|
|
|
two things :
1) you never said you didn't wan't the way i gave you
2) you say you solved it, but you don't give any feedback here on how you did it...
i'm curious to know how, because i don't really see how this is possible (or i did not understood the question).
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
What seems to be the problem here is that you don't realize what compile-time and run-time means. What you are trying to accomplish is as far as I know impossible. Once the compiler parses the line int b=0x20; it automatically defines a symbol in the data stack and initializes that space with the value of 0x20, which in base 10 is 32. The compiler however does not store any base information along with the value. Hence, the problem you are posing is unrealistig to say the least. Maybe I don't understand your question, but it really seems to me that you aren't really asking the right question.
Note that most answers are found by simply asking the right question!
I'm waiting for more information on the subject!
(also, as a note -- I think this is a post that doesn't necessarily belong in the C++/CLI area)
|
|
|
|
|
i have an app in c++ and i need to send an e-mail when certain conditions occurs, i´ve found many source code but is for c# and .net.
Pls anybody help me.
Thanks.
|
|
|
|
|
Check out http://www.codeproject.com/internet/csmtpconn.asp or the updated version at http://www.naughter.com/smtp.html
Brad Bruce
|
|
|
|
|
Ok, i have tried a few other sites, but have yet to get a response and i'm getting really nervous...
Tomorrow I have a C++ test in my grade 11 computer science course and my teacher gave us a few problems to do/practise at home. (Note we use Visual C++ from Visual Studio 6.0)
Problem 1. Have the user input a 4-digit character array or string. Have your program convert this string into an integer value without using the atoi function.
As it clearly states, i cannot use the atoi function. Now a previous question wanted the opposite (integer to char array) with itoa function and i got that working with the code i have in the txt file.
Problem 2. Have the user guess at random number. Have the computer tell the user either “Higher” or “Lower” until correct. The program will show the total number of guesses. Also, if the user is a moron, tell them so. For example, assume the correct number is 12. If the user inputs 7 and your program informs the user “higher”, if at any later time the user inputs a number of 7 or lower, the program is permitted to call the user a “moron”.
My question is if someone can please help me by coding this, just so that i can review the code and be ready for the test tomorrow. I've missed the class the last 4 days with the flu and have fallin a little behind. Also, if you could code it at a similar level as the code in the txt file, i would really appriciate it because thats how far our class as gotten so far. Please refer to the text file.
PS: I know it may not be exactly whta you'd want to do, but i would really appriciate it and it would help me dramatically.
Link to the .txt file...
http://www.megaupload.com/?d=RU48CFTR
|
|
|
|
|
MarkoOkuka wrote: Problem 1. Have the user input a 4-digit character array or string. Have your program convert this string into an integer value without using the atoi function.
A string is just an array of chars. Each char has a numeric value. If you work out the char values for numbers, you can easily turn them into digits, left to right, and multiply by 10/100/1000.
With regard to the second problem, all you need to do is keep their last guess in a variable, and then if they were lower, and go lower again, you have everything you need to work that out. What have you done so far on this ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
possibly a dump question, but better be safe....
if I have a class like this:
<br />
class Foo<br />
{<br />
std::vector<Foo2> vectorWithFoo2; <br />
};<br />
and then allocate a pointer of Foo
Foo* pFoo = new Foo;
the pFoo is allocated in the heap, right?
Now, each time I push_back a Foo2 into the vector, is it stored in the stack or the heap? I think its the heap but I wanted to be sure...
|
|
|
|
|
yes, pFoo is allocated in the heap. And the vector internal allocation is done in the heap.
|
|
|
|
|
|
I want to generate a custom warning at compile time in C++. I am working with Sun Studio 9, C++ 5.6 compiler. Prompt replies will be appreciated.
|
|
|
|
|
does #warning work?
I don't know your platform, but usually it does.
|
|
|
|
|
I have made a program to except user's input and use that input to execvp another program. The problem is that execvp has a prototype of int execvp(const char *file, char *const argv[]); and the user's input is a c++ style string (string input for instance). How can I convert that c++ style string into something at execvp can use? the c_str() function DOES NOT work.
|
|
|
|
|
Which argument are you having trouble with ? What format is the string you're getting as input ? c_str() does indeed return a char *, if you've got a std::string. argv is an array of char *, not just a char *.
What do you mean by 'it doesn't work'. A more meaningful error report would help those trying to help you.
Christian Graus - Microsoft MVP - C++
|
|
|
|