euc-kr, utf-8, utf-16, utf-32, std::string, std::wstring 변환 라이브러리좀 알려주세요

vivisection의 이미지

std::wstring 을 위 나열한 문자집합 전부로 변환해야 할 일이 생겼습니다
찾아보니까 iconv가 있는데 어려워서 모르겠고, MultiByteToWideChar() 함수는 std::string 을 euc-kr로 변환하는게 잘 안됩니다

wxString 이 가장 좋은것 같은데, wxString 하나때문에 wxWidgets 다운받고 설치하고 빌드하고 링크하고 하면 좀 오버인것 같습니다

iconv 어려워도 공부해서 해야하는건지, 아니면 다른 라이브러리가 있는지 알려주시면 감사하겠습니다

Anti-Lock의 이미지

저도 잘모르지만, 언젠가 필요 할 듯하여 찾아보니, 다음의 링크가 검색되었습니다.

http://ysoftman.blogspot.kr/2009/03/cc-iconv-euc-kr-utf-8.html

샘플 코드를 살펴보니, 그렇게 생각보다 어렵지 않은것 같습니다.
iconv_open 함수와 iconv 함수의 입/출력 인자 순서가 달라 조금은 헷갈릴수 있겠네요.

한편, glib 에는 g_utf8_to_utf16, g_ucs4_to_utf16 같은 함수들이 있는데,,
특정 인코딩인 'euc-kr'을 uft8 또는 utf16 으로 변환하는데 사용 할 수 있는 함수는 찾지 못하였습니다.

https://developer.gnome.org/glib/stable/glib-Unicode-Manipulation.html

참고로, https://kldp.org/node/154864 를 보면,
euc-kr, utf-8, utf-16, utf-32, ucs-2(요놈이 윈도우에서 유니코드라고 알려진. 찾아보니, utf-16의 서브셋인 모양입니다), ucs-4
뭔가 개념을 잘 잡아야 할 것 같습니다. (라이브러리는 문제 없겠지만요)

std::wsting 에 대해서는
https://www.gnu.org/software/libunistring/manual/html_node/The-wchar_005ft-mess.html
를 참고 하심이 좋을 것 같습니다. (윈도우즈에서는 utf-16 이나, utf-32 를 담기엔 적절하지 않다는 것 같습니다)

익명 사용자의 이미지

Character Set Conversion

Character Set Conversion — convert strings between different character sets

https://developer.gnome.org/glib/stable/glib-Character-Set-Conversion.html

gchar *
g_convert (const gchar *str,
gssize len,
const gchar *to_codeset,
const gchar *from_codeset,
gsize *bytes_read,
gsize *bytes_written,
GError **error);

gsize
g_iconv (GIConv converter,
gchar **inbuf,
gsize *inbytes_left,
gchar **outbuf,
gsize *outbytes_left);

vivisection의 이미지

고맙습니다

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.