File: miscucs.c

package info (click to toggle)
its-playback-time 0.2017-08-30.3c40fd3-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, trixie
  • size: 888 kB
  • sloc: ansic: 15,449; perl: 197; makefile: 29; sh: 1
file content (28 lines) | stat: -rw-r--r-- 745 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
 * Centralised Unicode-related helper functions, separate from misc.c
 * so that they can be omitted from tools that aren't including
 * Unicode handling.
 */

#include "putty.h"
#include "misc.h"

wchar_t *dup_mb_to_wc_c(int codepage, int flags, const char *string, int len)
{
    int mult;
    for (mult = 1 ;; mult++) {
        wchar_t *ret = snewn(mult*len + 2, wchar_t);
        int outlen;
        outlen = mb_to_wc(codepage, flags, string, len, ret, mult*len + 1);
        if (outlen < mult*len+1) {
            ret[outlen] = L'\0';
            return ret;
        }
        sfree(ret);
    }
}

wchar_t *dup_mb_to_wc(int codepage, int flags, const char *string)
{
    return dup_mb_to_wc_c(codepage, flags, string, strlen(string));
}