- Unicode test - 3 Updates
- Unicode test - 2 Updates
- About C++ and real-time OSs - 1 Update
- PVS-Studio: Critical errors in CryEngine V code - 3 Updates
- The newbie struggles with C++ - 1 Update
- std::variant<Dublin, Jerusalem, Melbourne, Prague, Austin, ...> - 1 Update
- std::byte - 1 Update
alexo <alessandro.volturno@libero.it>: Apr 05 02:36PM +0200 Hello all, I'm trying to write a test program to deal with Unicode characters on Windows. I've found that the way to insert it in a character type is to use wchar_t (but this is not a portable solution) and use the character format code L"\0xxx". this is the code I wrote after googling a bit (but not much :) /* code follows */ #include <iostream> #include <locale.h> using namespace std; int main() { char* locale = setlocale(LC_ALL, ""); wchar_t uc = L"\u0333"; wcout << uc << endl; return 0; } It outputs nothing |
alexo <alessandro.volturno@libero.it>: Apr 05 02:38PM +0200 Il 05/04/2017 14:36, alexo ha scritto: the message was sent too early. Thank you for your help. alessandro |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Apr 06 12:28AM +0200 On 06-Apr-17 12:07 AM, Stefan Ram wrote: > return EXIT_SUCCESS; > } > You also need a Windows version that is not too old. This is unfortunately ungood advice. The UTF-8 codepage generally doesn't work for console i/o, down at the API level. Using the Windows API, as is done above, you can use the direct console i/o functions. Using the C++ wide streams (portable) you can configure them via `_setmode`. Cheers!, - Alf |
ram@zedat.fu-berlin.de (Stefan Ram): Apr 05 10:07PM >Windows. I've found that the way to insert it in a character type is to >use wchar_t (but this is not a portable solution) and use the character >format code L"\0xxx". #include <stdio.h> #include <wchar.h> #include <Windows.h> int main() { //chcp 65001 UINT oldcp = GetConsoleOutputCP(); if (!SetConsoleOutputCP(CP_UTF8)) { fprintf(stderr, "chcp failed\n"); return EXIT_FAILURE; } unsigned char utf8data[] = { 'H', 0xc3, 0xa4, 'l', 0xC2, 0xA2, // "cent" 0xE2, 0x82, 0xAC, // "euro" 0xF0, 0x90, 0x8D, 0x88, // U+10348 'l', 0xc3, 0xb6, '!', '\n', 0x00 }; DWORD size=(DWORD)(sizeof(utf8data) / sizeof(*utf8data)) - 1; DWORD written = 0; BOOL success = WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), utf8data, size, &written, 0 ); if (!success) { fprintf(stderr, "WriteFile failed\n"); return EXIT_FAILURE; } SetConsoleOutputCP(oldcp); return EXIT_SUCCESS; } You also need a Windows version that is not too old. |
ram@zedat.fu-berlin.de (Stefan Ram): Apr 05 10:16PM >You also need a Windows version that is not too old. And you need to set a console font in the console, no, wait: a /Unicode/ font!, such as: Lucida Console or Consolas. |
"Chris M. Thomasson" <invalid@invalid.invalid>: Apr 05 01:47PM -0700 On 4/4/2017 10:53 AM, Bonita Montero wrote: > You don't even understand condition-variables. Sure seems that way. Imho, One needs to learn how to efficiently work with mutex/condvar relationship before they even think about using anything else! Wow! Just Wow. ;^o |
Gareth Owen <gwowen@gmail.com>: Apr 05 08:26AM +0100 > There was enough material for an article with the description of only > crucial errors. > Article: https://www.viva64.com/en/b/0495/ You have a weird idea of what constitutes a "crucial error". I'd hate to see the list of trivial ones. |
asetofsymbols@gmail.com: Apr 05 08:32AM -0700 Float Point numbers operator compare has to use epsilon... For example double x; .... No if(x==1.0) etc Yes if(absfordouble(x-1.0)<0.0001) etc |
Bonita Montero <Bonita.Montero@gmail.com>: Apr 05 05:48PM +0200 > Heck, what about this approximation for sqrt in a game: SSE includes RSQRTSS/PS for the usual 3D-graphis purpose. -- http://facebook.com/bonita.montero/ |
Jorgen Grahn <grahn+nntp@snipabacken.se>: Apr 05 05:36AM On Tue, 2017-04-04, Robert Wessel wrote: >>> Got it. I've been using Code::Blocks on Linux, the current version comes >>> with Valgrind already plugged-in, are there any recommended profiling >>> tools for that setup? I'm pretty sure good old gprof(1) will work. time(1), strace(1) and Valgrind may also be of use for this. Linux perf(1), too. And you need a way to run your program with realistic inputs so it runs into situations where it /might/ be too slow or resource-hungry. > slow. While it would normally be silly to use a profiler to *detect* > bad performance, using one to *locate* it is a much better idea that > the near-random guessing technique preferred by most programmers. You're right, of course. But bitrex didn't seem to have any actual problems with his code being too slow. I obsess too much about micro-performance myself, and he was (it seemed to me) about to make the same mistake. (It's fair to let him know, though, that when he /does/ need profiling tools, they /are/ available. I should have done that in my first posting.) /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o . |
woodbrian77@gmail.com: Apr 04 07:59PM -0700 Has your user group lost some of its pizzazz? Are topics like "Java" sometimes covered? I have an idea to help get things back on track. I'll travel to your location at my own expense if you would like to have me talk about the C++ Middleware Writer -- a free on line code generator -- at your meeting. What I hope to do is make it into a working vacation. https://meetingcpp.com/index.php/newsreader/items/c-user-group-meetings-in-april-2017.html I'm not sure if I'll do this more than one time. I'm willing to travel overseas if that's where the interest is. Brian Ebenezer Enterprises - Enjoy programming again. http://webEbenezer.net |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Mar 29 10:00PM +0100 On 29/03/2017 04:34, Daniel wrote: > g.next(); > } > But I know, I know, you don't see it. Sorry but you are talking nonsense. Individual Unicode codepoints represented by a single scalar type are just as useless as variable length UTF-8 encoded codepoints as far as wanting an atomic "character" is concerned; you would know this if you did any serious i18n and/or Unicode work. I strongly disagree with your assertion that UTF-8 should only be used during "serialization" and that an application should be unaware of it: you are obviously a newbie or suffering from Dunning-Kruger effect if you hold such views. Did you know Linux uses UTF-8 for filenames? The text edit widget in my GUI library accepts UTF-8 as input; caches it as both UTF-32 and font glyphs (after any glyph shaping performed for e.g. Arabic script) and it works a treat so I do have practical knowledge in this area. /Flibble |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment