Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wlength = GetShortPathNameW(cpy,0,0);
- LPWSTR shortp = (LPWSTR)calloc(wlength,sizeof(WCHAR));
- GetShortPathNameW(cpy,shortp,wlength);
- clength = WideCharToMultiByte(CP_OEMCP, WC_NO_BEST_FIT_CHARS, shortp, wlength, 0, 0, 0, 0);
- LPSTR cpath = (LPSTR)calloc(clength,sizeof(CHAR));
- WideCharToMultiByte(CP_OEMCP, WC_NO_BEST_FIT_CHARS, shortp, wlength, cpath, clength, 0, 0);
- char *
- #include <stdio.h>
- #include <stdlib.h>
- #include <assert.h>
- #include <wchar.h>
- wchar_t *p = L"ABCDEFuA010"; // ascii only but last which won't be
- // converted properly...
- char *wchar2char(wchar_t *s)
- {
- int i;
- size_t l = wcslen(s);
- char *d = malloc(l+1); assert(d != NULL);
- for(i = 0; i < l; i++) {
- if ( s[i] > 127 ) d[i] = '?'; // no ascii
- else d[i] = s[i] & 0xff;
- }
- d[l] = 0;
- return d;
- }
- int main()
- {
- //wprintf(p);
- char *t = wchar2char(p);
- printf(t);
- free(t);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement