⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 codeset.c

📁 飞鸽传书的linux源代码
💻 C
字号:
#include <errno.h>#include <glib.h>#include "common.h"#define IPMSG_INTERNAL_CODE "UTF-8"#define IPMSG_PROTO_CODE    "CP932"intconvert_string_internal(const char *string,const gchar **to_string){  int rc=0;  gchar *converted_string;  gsize read_len;  gsize write_len;  GError *error_info=NULL;  if ( (!string) || (!to_string) )    return -EINVAL;  converted_string=g_convert((const gchar *)string,			     -1, /* ヌルターミネート */			     IPMSG_INTERNAL_CODE,			     IPMSG_PROTO_CODE,			     &read_len,			     &write_len,			     &error_info);  rc=-EINVAL;  if (!converted_string) {    if (error_info) {      err_out("%s\n",error_info->message);      rc=error_info->code;      g_error_free(error_info);    }    if (rc>0)      rc=-rc;    return rc;  }  *to_string=converted_string;  return 0;}intconvert_string_ipmsg_proto(const char *string,const gchar **to_string){  int rc=0;  gchar *converted_string;  gsize read_len;  gsize write_len;  GError *error_info=NULL;  if ( (!string) || (!to_string) )    return -EINVAL;  converted_string=g_convert((const gchar *)string,			     -1, /* ヌルターミネート */			     IPMSG_PROTO_CODE,			     IPMSG_INTERNAL_CODE,			     &read_len,			     &write_len,			     &error_info);  rc=-EINVAL;  if (!converted_string) {    if (error_info) {      err_out("%s\n",error_info->message);      rc=error_info->code;      g_error_free(error_info);    }    if (rc>0)      rc=-rc;    return rc;  }  *to_string=converted_string;  return 0;}intconvert_string_ipmsg_locale(const char *string,const gchar **to_string){  int rc=0;  gchar *converted_string;  gsize read_len;  gsize write_len;  GError *error_info=NULL;  if ( (!string) || (!to_string) )    return -EINVAL;  converted_string=g_locale_from_utf8((const gchar *)string,			     -1, /* ヌルターミネート */			     &read_len,			     &write_len,			     &error_info);  if (!converted_string) {    if (error_info) {      err_out("%s\n",error_info->message);      rc=error_info->code;      g_error_free(error_info);    }    if (rc>0)      rc=-rc;    return rc;  }  *to_string=converted_string;  return 0;}intconvert_string_ipmsg_filename(const char *string,const gchar **to_string){  int rc=0;  gchar *converted_string;  gsize read_len;  gsize write_len;  GError *error_info=NULL;  if ( (!string) || (!to_string) )    return -EINVAL;  converted_string=g_filename_from_utf8((const gchar *)string,			     -1, /* ヌルターミネート */			     &read_len,			     &write_len,			     &error_info);  rc=-EINVAL;  if (!converted_string) {    if (error_info) {      err_out("%s\n",error_info->message);      rc=error_info->code;      g_error_free(error_info);    }    if (rc>0)      rc=-rc;    return rc;  }  *to_string=converted_string;  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -