Co mam zrobić żebym mógł używać wstring wcout wcin?

0

Prosiłbym o pomoc. Co mam zrobić żebym mógł używać wstring wcout wcin?
Zmienić coś w pliku iostream?
Niech ktoś spojrzy i podpowie:

// Standard iostream objects -*- C++ -*-

// Copyright (C) 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING.  If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.

// As a special exception, you may use this file as part of a free software
// library without restriction.  Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License.  This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.

//
// ISO C++ 14882: 27.3  Standard iostream objects
//

/** @file iostream
 *  This is a Standard C++ Library header.  You should @c #include this header
 *  in your programs, rather than any of the "st[dl]_*.h" implementation files.
 */

#ifndef _GLIBCXX_IOSTREAM
#define _GLIBCXX_IOSTREAM 1

#pragma GCC system_header

#include <bits/c++config.h>
#include <ostream>
#include <istream>

namespace std 
{
  /**
   *  @name Standard Stream Objects
   *
   *  The &lt;iostream&gt; header declares the eight <em>standard stream
   *  objects</em>.  For other declarations, see
   *  http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#10 and the
   *  @link s27_2_iosfwd I/O forward declarations @endlink
   *
   *  They are required by default to cooperate with the global C library's
   *  @c FILE streams, and to be available during program startup and
   *  termination.  For more information, see the HOWTO linked to above.
  */
  //@{
  extern istream cin;		///< Linked to standard input
  extern ostream cout;		///< Linked to standard output
  extern ostream cerr;		///< Linked to standard error (unbuffered)
  extern ostream clog;		///< Linked to standard error (buffered)

#ifdef _GLIBCXX_USE_WCHAR_T
  extern wistream wcin;		///< Linked to standard input
  extern wostream wcout;	///< Linked to standard output
  extern wostream wcerr;	///< Linked to standard error (unbuffered)
  extern wostream wclog;	///< Linked to standard error (buffered)
#endif
  //@}

  // For construction of filebuffers for cout, cin, cerr, clog et. al.
  static ios_base::Init __ioinit;
} // namespace std

#endif /* _GLIBCXX_IOSTREAM */

Ta dyrektywa jest chyba odpowiedzialna za te wstringi itd.
Na tym forum http://forum.ks-ekspert.pl/topic/85683-dev-cpp-i-wcoutwcin/
np. było też o dodaniu:

#define _GLIBCXX_USE_WCHAR_T
#include<cwctype>
#include<cwchar>

ale po tym wyskakują błędy(w załaczniku)

Może też przyda wam się ta informacja. Używam dev c++ wersja 4.9.9.2

0
  1. Wrzuc to w <code>.
  2. Screena tez moglbys do posta walnac.
  3. Zaktualizuj kompilator.
  4. Zaktualizuj zrodlo wiedzy :P
  5. Jak to zrobisz, wroc na forum z nowymi bledami :)
0

w visualu pamiętam ,że można było zmienić w opcjach kompialtora kodowanie na rozszeżony zestaw znaków. NIe jestem pewien ,ale chyba musisz właśnie to ustawić. dev c++ korzysta z MinGw ,ale w opcjach dev cpp na bank możesz przesłać dodatkowe komendy do kompilatora. Musisz zajrzeć do manuala GCC i to jakoś przestawić.

0

Używam dev c++ wersja 4.9.9.2

Zaktualizuj do nowszej wersji lub pobierz coś normalnego ehm, przynajmniej mniej zabugowanego i sprawdź ponownie.
Dla przykładu w Code::Blocks działa to bez żadnych udziwnionych dodatkowych konfiguracji.

0

Dobra. Zainstalowałem najnowszą wersję deva(5.4.2), czyli nowsza wersja kompilatora, przez aktualizacje nie próbowałem bo nie wiem co wybrać.
Wykasowałem #define _GLIBCXX_USE_WCHAR_T z pliku *.cpp i mam tylko jeden błąd.

[Error] converting to execution character set: Illegal byte sequence

Ale oczywiście alej się czepia linijki

wcout<<L"ą";

A co do innych programów jak code blocks to dzięki. Ale gubię się w takich programach. Dev jest wygodniejszy

dodanie znacznika <quote> dla treści błędu - fp

0

Probowales bez L na poczatku? Bo mi bez L sie kompiluje, jednak nic nie wyswietla bo nie mam odpowiedniego kodowania konsoli i ciezko mi to sprawdzic.
Dodatkowo z L sie kompiluje pod msvc :)

0

Ustaw, jeśli nie jest ustawione, kodowanie środowiska na polskie, np. windows-1250. Dodatkowo musisz ustawić locale strumienia, a to w MinGW może być problemem.

// gdzieś na początku
wcout.imbue(locale(".852")); // kodowanie konsoli w WinXP i starszych
...

wcout << L"ą";
0

w GCC (czyli Dev-C++, Code::Blocks, MinGW, QtCreator) pod Windows polskie litery pod wcout są zwalone i nigdy nie udało mi się zrobić żeby działało.

EDIT: po napisaniu powyższego mnie olśniło.

#include <iostream>
#include <clocale>
using namespace std;

int main()
{
  setlocale(LC_CTYPE, ".OCP");
  wcout << L"zażółć gęślą jaźń";
}

ważne: zapisać plik jako UTF-8.

0

Dobra. Znalazłem po długim czasie coś takiego:

int main(){
 cout << "Problem polskich liter " << '\n'; 
  cout << "ąćęłńóśźż" << '\n'; 
  cout << "ĄĆĘŁŃÓŚŹŻ" << '\n'; 
  system("PAUSE"); 
  char text[64]; 
  CharToOem("Próba rozwiązania wg podpowiedzi Akane ", text); 
  cout << text << '\n'; 
  CharToOem("ąćęłńóśźż", text); 
  cout << text << '\n'; 
  CharToOem("ĄĆĘŁŃÓŚŹŻ", text); 
  cout << text << '\n'; 
  system("PAUSE"); 
  return 0; 
} 
0

A nie prościej:

int main()
  {
   SetConsoleOutputCP(1250);
   cout<<"ąćęłńóśźż"<<endl; 
   cout<<"ĄĆĘŁŃÓŚŹŻ"<<endl;
   return 0;
  }

?

0

Dobra. Znalazłem po długim czasie coś takiego:

Podobno chciałeś użyć wcout. Podane „rozwiązanie” wcale nie używa wcout. Dlaczego więc pytałeś jakby ci zależało konkretnie na wcout, skoro zależało ci po prostu na polskich literach?

Na przyszłość zadawaj właściwe pytania, zaoszczędzisz wszystkim czasu i nerwów.

1 użytkowników online, w tym zalogowanych: 0, gości: 1