|
Thanks Mark,
The page is very helpful.
Two more questions,
1. In the article, I think codepage has the same meaning of encoding -- mapping table between character and numbers. Is that correct?
2. Differences between multi-byte and wide character? I think they are both characters which are represented by more than one bytes. Why on Windows they are distinguished?
regards,
George
|
|
|
|
|
George_George wrote: 1. In the article, I think codepage has the same meaning of encoding -- mapping table between character and numbers. Is that correct?
If by character, you mean the character we see, and by numbers you mean the character codes, then
yes.
George_George wrote: 2. Differences between multi-byte and wide character? I think they are both characters which are represented by more than one bytes. Why on Windows they are distinguished?
To different ways to encode characters. With unicode, all character codes are 2 bytes (although
I think Unicode can support longer codes, I forget). With MBCS character codes can be one or
more bytes.
Either way, the codes need to be mapped to a character glyph to present the character to the
user. That mapping is done using the code page.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks Mark!
Previously, I think multibyte character is a specific encoding (codepage). But after discussion with you, I think I am wrong. Multibyte character on Windows is a general term which is used for representing character which could be stored in more than one byte. And several encoding (codepage), like UTF-8, ANSI, ... could be called as multibyte character. Is my understanding correct?
If my understanding is correct, I am wondering what about wide character? Seems wide character on Windows is the same as UTF-16? i.e. wide character == UTF-16 encoding (or UTF-16 codepage).
regards,
George
|
|
|
|
|
I think we're still mixing encoding and codepages
The "encoding" would be the value and format of the byte(s) used to store a character code.
The "code page" is the the mapping of encoded character values to a drawing of the character.
An example - if you have a bunch of Chinese Unicode-encoded characters in an array. If you try
to render those characters to the screen using the ANSI codepage, you'll get a bunch of boxes
drawn, indicating there was no character glyph in the codepage matching the character code.
If you use a codepage that does contain the Chinese character glyphs, then the characters will be
drawn.
UTF-16 is a Unicode encoding. I believe it allows for two-byte or 4-byte character codes but
I personally have never used larger than 2-byte (wide) characters.
UTF-16 is a more specific format than what we refer to in our C++ code. The different flavors
of UTF-16 have different byte ordering and/or bit positions. This strict definition provides
for cross-platform portablitity - the byte order and layout will be the same on all machines -
it's up to the users of the character codes to translate them to a suitable format for the
system they are used on.
If you search Google on "UTF8" or "UTF16" you'll find lots of information on the specifics of
those Unicode encodings.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thank you very much Mark! Great answer!!
Let us come back to the original question -- multibyte character and wide character.
Previously, I think multibyte character is a specific encoding (codepage). But after discussion with you, I think I am wrong. Multibyte character on Windows is a general term which is used for representing character which could be stored in more than one byte. And several encoding (codepage), like UTF-8, ANSI, ... could be called as multibyte character. Is my understanding correct?
If my understanding is correct, I am wondering the differences between multi-byte and wide character? I think they are both characters which are represented by more than one bytes. Why on Windows they are distinguished?
i.e. I think wide character is a subset of multibyte character. But seems on Windows they are two different types of character.
regards,
George
|
|
|
|
|
On some client's computer the (.NET) XmlDocument.Save() fails with some weird internal error such as:
============== (.NET stacktrace)
Exception : System.IO.IOException
Message : Unknown error "-1".
Source : mscorlib
Help :
Stack :
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.Xml.XmlDocument.Save(String filename)
===============
I have reported such a problem to microsoft and they just told me they need more information such as a mini dump.
how do I do one?
|
|
|
|
|
Without writing new code, you can run DrWatson. When the program has a crash, DrWatson can write it to a minidump.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc.</A>
|
|
|
|
|
ha ok...
but it doesn't show when I run my .NET program. And if I don't catch the exception it shows a .NET exception box, not DrWatson.
Beside, from my remote memories of DrWatosn, I don't know how to tell it to save anything
Could you give some more detailed tip please?
|
|
|
|
|
|
This may be trivial for most of you. I have been programming for about 20 years, now, I have a Computer Science degree, and I have never had any one define, for me, what a wrapper is. I am sure I have probably made them and used them without knowing that is what they are called. To me a wrapper is that little bit of paper I have to go through to get to a piece of gum. Can someone tell me what is meant, in the programming world, by the term wrapper?
|
|
|
|
|
To me, from an object-oriented point of view - there's the concept of Encapsulation[^].
A wrapper provides the "capsule" for encapsulation.
For example, a wrapper class provides a public interface to a hidden/private implementation.
My 1 cent.
Mark
p.s. I don't know if the article I linked to is good - I just know it saved me some typing
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
MFC can be compared to a Wrapper AROUND Win32 calls; it makes creating and managing UI (mostly) easier for the programmers.
Wrapper functions or classes are created to make API simpler to use.
|
|
|
|
|
huehue wrote: To me a wrapper is that little bit of paper I have to go through to get to a piece of gum
I think you've found your way.
More specifically (but informally), we usually talk about Wrappers only in OOP. For instance MFC builds objects (wrappers) around plain C API. Wrapper is a broad concept of OOP, you can find specialized applications of this concept (for instance) in Proxy , Facade , Adapter design patterns.
hope that helps
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
A wrapper is some code or object which simplifies or adapts the use of some service by isolating the user from the complexities/specifics of its interface; often providing a simpler or more portable interface. Conceptually it "wraps" around the old interface.
Steve
|
|
|
|
|
This helps, thanks guys...
|
|
|
|
|
I’m working in a big MFC application. I now have Several Forms to add into this application. The original developer says there is no reason to stick with MFC. So I need to convert this MFC application. I’m looking for websites and/or books on converting. Both the old and new application will need to be written in C++.
Any advice would help.
Thanks
Programmer
Glenn Earl Graham
Austin, TX
|
|
|
|
|
If it's not broken, don't change it.
question to ask yourself :
Will that change bring an additional value to your development process in the short, medium and long term
Can you spend the time doing Research to do this ? Can you spend the time to do the additional development ?
|
|
|
|
|
|
I have it on order. Thanks
Programmer
Glenn Earl Graham
Austin, TX
|
|
|
|
|
Hi, I am using Visual Studio 2005, I build new win32 console application project and I tried to compile this simple code
<br />
#include "stdafx.h"<br />
#include <iostream><br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
using namespace std;<br />
char question[] = "Please, enter your first name: ";<br />
char greeting[] = "Hello, ";<br />
char yourname [80];<br />
cout << question;<br />
cin >> yourname;<br />
cout << greeting << yourname << "!";<br />
return 0;<br />
}
But I get error of
error LNK2019: unresolved external symbol "__declspec(dllimport) class std::basic_ostream<char,struct std::char_traits<char> > &__cdecl std::operator<<<char,struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (__imp_??$?6DU?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z) referenced in function _wmain
But when I comment out the line
it compile successfully.
I think there is library file missing, but don't know which one. I googled out so many website and still can't find out the solutions, any ideas how to solve this ?
Thanks.
-- modified at 1:33 Sunday 6th May, 2007
|
|
|
|
|
esia wrote: I think there is library file missing, but don't know which one.
Which ones are you linking with?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for your reply, I didn't link any library file, but when I read from this solved post where they include the path to msvcprt.lib, http://www.tek-tips.com/viewthread.cfm?qid=1354561&page=1
But when I did that, I still get the same error. Any ideas how ?
|
|
|
|
|
The following are the default libraries for a Visual Studio 2005 C++ Win32 Console application: kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Thanks for your reply, but what you trying to explain to me ?
|
|
|
|
|
Are you using the /nodefaultlib compiler switch?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|