Click here to Skip to main content

Comments by Nemanja Trifunovic (Top 19 by date)

Nemanja Trifunovic at 13-May-11 8:31am View
   
Deleted
That's fine - just be aware that it solves a slightly different problem: converting UTF-16 to/from current system code page, which can really be anything. Internaly it uses Windows conversion API.
Nemanja Trifunovic at 14-Apr-11 11:43am View
   
+5.
Nemanja Trifunovic at 12-Apr-11 14:07pm View
   
Why does this question have MemoryBarrier tag?
Nemanja Trifunovic at 4-Apr-11 22:50pm View
   
Deleted
As I repeated several times: this is from ASCII to Unicode. ASCII characters are *always* < 127. Encoding detection is way beyond the scope of this little tip.
Nemanja Trifunovic at 30-Mar-11 14:19pm View
   
Deleted
The sample could be improved. std::string is guaranteed to store memory in a single block (well, at least in C++ 2011, but all current STL implementations do that anyway) so you can just reserve the string buffer with an appropriate size (which BTW needs to be done via a separate call to WideCharToMultiByte - your sample will work only for ASCII characters) and pass it directly instead of dealing with a temporary array.
Nemanja Trifunovic at 30-Mar-11 14:12pm View
   
Deleted
Reason for my vote of 5
Nice. However, be aware that your approach is not exactly equivalent to the original. CP_UTF8 means the resulting string will be UTF-8 encoded. CW2A macro converts the string to the system encoding on the user's machine.
Nemanja Trifunovic at 30-Mar-11 11:07am View
   
Deleted
Well, you said: "but when you are dealing with unicode data this doesn't work fine...". My point is that it works as described - it converts an ASCII string to a UTF-16 Unicode one (on Windows). The tip is not about best practices for developing "world-ready" software.
Nemanja Trifunovic at 30-Mar-11 8:42am View
   
Deleted
Mital, please check the title of the tip: "ASCII strings to Unicode". Of course it does not work if anything other than ASCII is stored in the source string; the point is that if you know you have only ASCII there is no way to call conversion functions - all you need to do is "widen" existing characters to.
Nemanja Trifunovic at 29-Mar-11 13:14pm View
   
The question is tagged with C, C++. Your example is in neither of these languages.
Nemanja Trifunovic at 29-Mar-11 8:58am View
   
Deleted
Yep, very good :)
Nemanja Trifunovic at 29-Mar-11 8:56am View
   
Deleted
@Gernot: The title of my tip is clear: from ASCII to Unicode. ASCII is a 7 bit encoding and there can't be any characters > 127. If you have some other encoding of course you need to use something like MultiByteToWideChar or iconv.
Nemanja Trifunovic at 28-Mar-11 10:26am View
   
IMHO, it is an incomplete answer. OP wants to know how to pass a multidimensional array to a function. Passing just a pointer without the size(s) is not enough.
Nemanja Trifunovic at 28-Mar-11 10:24am View
   
It is not about style here. Because array decays into pointers when passed as function arguments, there is no way to determine the size of the array from within a function. Therefore, either the size needs to be passed as a separate parameter, or array needs to be terminated by some well-known value that the function will recognize.
Nemanja Trifunovic at 27-Mar-11 17:06pm View
   
It is not a good idea to hardcode the array size within the function. It is better to pass it as another parameter instead.
Nemanja Trifunovic at 16-Mar-11 22:22pm View
   
In my sample, it is the derived classs that is instantiated and it does not have any virtual functions.
Nemanja Trifunovic at 17-Feb-11 10:45am View
   
You can distribute the dll's even without the redistributable package - the difference is, depending on the version of VC++ (or even Windows?) you need to supply a manifest file together with the dlls.
Nemanja Trifunovic at 27-Dec-10 10:34am View
   
Microsoft replaced the Intellisense C++ compiler completely and the new one was not ready for C++/CLI in time for VS2010.
Nemanja Trifunovic at 30-Sep-10 11:30am View
   
Deleted
It would be interesting to add that early in C++ days there was no delete[] version, and plain delete was supposed to be used to clean up both after new and new[]. Of course, one should not assume that it would be OK to do such a thing nowdays.
Nemanja Trifunovic at 25-May-10 11:58am View
   
This is a correct answer. References are in practice implemented as pointers, but that is just an implementation detail. A reference is really an alias.
As I stated in my answer

Advertise | Privacy | Mobile
Web02 | 2.8.150326.1 | Last Updated 1 Jan 1900
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid