\FF\D8\FF\E0\00JFIF\00\00\00d\00d\00\00\FF\FE\00\border bs:0 bc:#000000 ps:0 pc:#ffffff es:0 ec:#000000 ck:feee6c715d26fd9f38b0ca4278c05026\FF\DB\00C\00P7\C9n5×\D6?\BDê\9Ds\EBp\9F[`8m\B7)o\B5\E8\E6I\99\FE3]]A2\BA\8Cw\D6E\93\\DEv\C8\009\F2\F1NI?uc\\F5\EA\96k\xN<~buv\EA\C8\D7 \8B\84\CEcxI\BBg\AE\9E=\D6+n\EC\80\C8A\8C\AE\EB\CF\D5\DA\E9"2\A4\B9j5\EB\F3W\B63\96\B30Yu\DA\FC8\ED\DF\E7Ms\FB\F1\8E\B3\FA\EA\E8\E6(\883zs\F2_\8DFk\8Bh \00\8C\DCw\D3R\B5+6X\BA\B2\C4j\AB0\B4\FCMw\C2I\8E\9B\E3\A9~9u\FA\D3l\80\C8%p\EE\FDn2€ \00 $\FEj\C4e\A9\DB\~\95\A7\A5\80EK\BB\8DDsP\00@@AD'k\CF\E8\DB\D2(\80\9AK\D3\85\D6lb\F2\BA\8C*\80\00)\95 59\A3R:\F3\CE"\B6\80\88\00\00i1u4ê\E9\F2á\A6\A2\FACM\93WMb*\E0*\00\00\00\00\00(\A8\80\00\00\80\00\00\00\00\00\00\00\00\00\FF\D9 C/// /* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html * ******************************************************************************* ******************************************************************************* * * Copyright (C) 1999-2007, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* * file name: uresb.c * encoding: UTF-8 * tab size: 8 (not used) * indentation:4 * * created on: 2000sep6 * created by: Vladimir Weinstein */ /****************************************************************************** * This program prints out resource bundles - example for * ICU workshop * TODO: make a complete i18n layout for this program. ******************************************************************************/ #include "unicode/putil.h" #include "unicode/ures.h" #include "unicode/ustdio.h" #include "unicode/uloc.h" #include "unicode/ustring.h" #include "uoptions.h" #include "toolutil.h" #include #include #ifdef WIN32 #include #else #include #endif #define URESB_DEFAULTTRUNC 40 static char *currdir = NULL; /*--locale sr_YU and --encoding cp855 * are interesting on Win32 */ static const char *locale = NULL; static const char *encoding = NULL; static const char *resPath = NULL; static const int32_t indentsize = 4; static UFILE *outerr = NULL; static int32_t truncsize = URESB_DEFAULTTRUNC; static UBool trunc = false; const UChar baderror[] = { 0x0042, 0x0041, 0x0044, 0x0000 }; const UChar *getErrorName(UErrorCode errorNumber); void reportError(UErrorCode *status); static UChar *quotedString(const UChar *string); void printOutBundle(UFILE *out, UResourceBundle *resource, int32_t indent, UErrorCode *status); void printIndent(UFILE *out, int32_t indent); void printHex(UFILE *out, const int8_t *what); static UOption options[]={ UOPTION_HELP_H, UOPTION_HELP_QUESTION_MARK, { "locale", NULL, NULL, NULL, 'l', UOPT_REQUIRES_ARG, 0 }, UOPTION_ENCODING, { "path", NULL, NULL, NULL, 'p', UOPT_OPTIONAL_ARG, 0 }, { "truncate", NULL, NULL, NULL, 't', UOPT_OPTIONAL_ARG, 0 }, UOPTION_VERBOSE }; static UBool VERBOSE = false; extern int main(int argc, char* argv[]) { UResourceBundle *bundle = NULL; UErrorCode status = U_ZERO_ERROR; UFILE *out = NULL; int32_t i = 0; const char* arg; char resPathBuffer[1024]; #ifdef WIN32 currdir = _getcwd(NULL, 0); #else currdir = getcwd(NULL, 0); #endif argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options); /* error handling, printing usage message */ if(argc<0) { fprintf(stderr, "error in command line argument \"%s\"\n", argv[-argc]); } if(argc<2 || options[0].doesOccur || options[1].doesOccur) { fprintf(stderr, "usage: %s [-options] locale(s)\n", argv[0]); return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR; } if(options[2].doesOccur) { locale = options[2].value; } else { locale = 0; } if(options[3].doesOccur) { encoding = options[3].value; } else { encoding = NULL; } if(options[4].doesOccur) { if(options[4].value != NULL) { resPath = options[4].value; /* we'll use users resources */ } else { resPath = NULL; /* we'll use ICU system resources for dumping */ } } else { strcpy(resPathBuffer, currdir); /*strcat(resPathBuffer, U_FILE_SEP_STRING); strcat(resPathBuffer, "uresb");*/ resPath = resPathBuffer; /* we'll just dump uresb samples resources */ } if(options[5].doesOccur) { trunc = true; if(options[5].value != NULL) { truncsize = atoi(options[5].value); /* user defined printable size */ } else { truncsize = URESB_DEFAULTTRUNC; /* we'll use default omitting size */ } } else { trunc = false; } if(options[6].doesOccur) { VERBOSE = true; } outerr = u_finit(stderr, locale, encoding); out = u_finit(stdout, locale, encoding); for(i = 1; i < argc; ++i) { status = U_ZERO_ERROR; arg = getLongPathname(argv[i]); u_fprintf(out, "uresb: processing file \"%s\" in path \"%s\"\n", arg, resPath); bundle = ures_open(resPath, arg, &status); if(U_SUCCESS(status)) { u_fprintf(out, "%s\n", arg); printOutBundle(out, bundle, 0, &status); } else { reportError(&status); } ures_close(bundle); } u_fclose(out); u_fclose(outerr); return 0; } void printIndent(UFILE *out, int32_t indent) { char inchar[256]; int32_t i = 0; for(i = 0; i truncsize) { printIndent(out, indent); u_fprintf(out, "// WARNING: this string, size %d is truncated to %d\n", len, truncsize/2); len = truncsize/2; } */ printIndent(out, indent); if(key != NULL) { u_fprintf(out, "%s { \"%S\" } ", key, string); } else { u_fprintf(out, "\"%S\",", string); } if(VERBOSE) { u_fprintf(out, " // STRING"); } u_fprintf(out, "\n"); free(string); } break; case URES_INT : printIndent(out, indent); if(key != NULL) { u_fprintf(out, "%s", key); } u_fprintf(out, ":int { %li } ", ures_getInt(resource, status)); if(VERBOSE) { u_fprintf(out, " // INT"); } u_fprintf(out, "\n"); break; case URES_BINARY : { int32_t len = 0; const int8_t *data = (const int8_t *)ures_getBinary(resource, &len, status); if(trunc && len > truncsize) { printIndent(out, indent); u_fprintf(out, "// WARNING: this resource, size %li is truncated to %li\n", len, truncsize/2); len = truncsize/2; } if(U_SUCCESS(*status)) { printIndent(out, indent); if(key != NULL) { u_fprintf(out, "%s", key); } u_fprintf(out, ":binary { "); for(i = 0; i 0) { u_fprintf(out, "%d ", data[len-1]); } u_fprintf(out, "}"); if(VERBOSE) { u_fprin