0
C++에서 UTF-8에서 라틴어 (ISO-8859-1)로 변환하는 코드를 작성하는 방법을 알고 싶습니다. úsernameC++에서 UTF-8에서 라틴어 (ISO-8859-1)로 변환
을는 결과 제공 : http://www.unicodetools.com/unicode/utf8-to-latin-converter.php
삽입 값을 :
은 다음 웹 사이트는 변환이 필요 않습니다 사용자 이름
난에서 비슷한 작업을 수행하는 코드의 조각을 가지고를 이전 게시물은 문자열을 변환하지 못했습니다.
int utf8_to_unicode(std::deque<int> &coded)
{
int charcode = 0;
int t = coded.front();
coded.pop_front();
if (t < 128)
{
return t;
}
int high_bit_mask = (1 << 6) -1;
int high_bit_shift = 0;
int total_bits = 0;
const int other_bits = 6;
while((t & 0xC0) == 0xC0)
{
t <<= 1;
t &= 0xff;
total_bits += 6;
high_bit_mask >>= 1;
high_bit_shift++;
charcode <<= other_bits;
charcode |= coded.front() & ((1 << other_bits)-1);
coded.pop_front();
}
charcode |= ((t >> high_bit_shift) & high_bit_mask) << total_bits;
return charcode;
}
도와주세요.
[iconv] (http://en.wikipedia.org/wiki/Iconv) 유용 할 수 있습니다. –
@BasileStarynkevitch 소스 코드 내에서이 변환을 하드 코딩하는 솔루션을 찾고 있는데 – user2724841
Iconv는 [libiconv] (http://www.gnu.org/software/libiconv/) 라이브러리이기도합니다. 소스 코드에서 변환을 하드 코딩하는 것이 무슨 뜻인지 이해할 수는 없습니다. 소스 코드 (예 :'emacs ')에 사용 된 텍스트 편집기를 원하는 인코딩으로 저장하도록 구성 할 수 있습니까? –