$10 GRAYBYTE WORDPRESS FILE MANAGER $25

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/alt/alt-nodejs19/root/usr/share/doc/alt-nodejs19-libicu-devel/samples/msgfmt/

HOME
Current File : /opt/alt/alt-nodejs19/root/usr/share/doc/alt-nodejs19-libicu-devel/samples/msgfmt//util.cpp
/**********************************************************************
 * © 2016 and later: Unicode, Inc. and others.
 * License & terms of use: http://www.unicode.org/copyright.html
 ***********************************************************************
 ***********************************************************************
 * COPYRIGHT:
 * Copyright (c) 1999-2010, International Business Machines Corporation and
 * others. All Rights Reserved.
 ***********************************************************************/

#include "unicode/unistr.h"
#include <stdio.h>
#include <stdlib.h>

using namespace icu;

// Verify that a UErrorCode is successful; exit(1) if not
void check(UErrorCode& status, const char* msg) {
    if (U_FAILURE(status)) {
        printf("ERROR: %s (%s)\n", u_errorName(status), msg);
        exit(1);
    }
    // printf("Ok: %s\n", msg);
}
                                                      
// Append a hex string to the target
static UnicodeString& appendHex(uint32_t number, 
                         int8_t digits, 
                         UnicodeString& target) {
    static const UnicodeString DIGIT_STRING("0123456789ABCDEF");
    while (digits > 0) {
        target += DIGIT_STRING[(number >> ((--digits) * 4)) & 0xF];
    }
    return target;
}

// Replace nonprintable characters with unicode escapes
UnicodeString escape(const UnicodeString &source) {
    int32_t i;
    UnicodeString target;
    target += "\"";
    for (i=0; i<source.length(); ++i) {
        UChar ch = source[i];
        if (ch < 0x09 || (ch > 0x0A && ch < 0x20) || ch > 0x7E) {
            target += "\\u";
            appendHex(ch, 4, target);
        } else {
            target += ch;
        }
    }
    target += "\"";
    return target;
}

// Print the given string to stdout
void uprintf(const UnicodeString &str) {
    char *buf = 0;
    int32_t len = str.length();
    // int32_t bufLen = str.extract(0, len, buf); // Preflight
    /* Preflighting seems to be broken now, so assume 1-1 conversion,
       plus some slop. */
    int32_t bufLen = len + 16;
	int32_t actualLen;
    buf = new char[bufLen + 1];
    actualLen = str.extract(0, len, buf/*, bufLen*/); // Default codepage conversion
    buf[actualLen] = 0;
    printf("%s", buf);
    delete [] buf;
}

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
31 Aug 2024 8.02 AM
root / root
0755
answers
--
31 Aug 2024 8.02 AM
root / root
0755
Makefile
0.603 KB
19 Oct 2022 7.53 AM
root / root
0644
README.TXT
3.067 KB
19 Oct 2022 7.53 AM
root / root
0644
main.cpp
1.526 KB
19 Oct 2022 7.53 AM
root / root
0644
msgfmt.sln
1.174 KB
19 Oct 2022 7.53 AM
root / root
0644
msgfmt.vcxproj
8.069 KB
19 Oct 2022 7.53 AM
root / root
0644
msgfmt.vcxproj.filters
0.944 KB
19 Oct 2022 7.53 AM
root / root
0644
util.cpp
2.235 KB
19 Oct 2022 7.53 AM
root / root
0644
util.h
0.851 KB
19 Oct 2022 7.53 AM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF