[Ttssh2-commit] [8434] LoadFileWW() 追加

scmno****@osdn***** scmno****@osdn*****
2019年 12月 9日 (月) 23:39:26 JST


Revision: 8434
          https://osdn.net/projects/ttssh2/scm/svn/commits/8434
Author:   zmatsuo
Date:     2019-12-09 23:39:25 +0900 (Mon, 09 Dec 2019)
Log Message:
-----------
LoadFileWW() 追加

Modified Paths:
--------------
    branches/unicode_buf/teraterm/ttpmacro/fileread.cpp
    branches/unicode_buf/teraterm/ttpmacro/fileread.h

-------------- next part --------------
Modified: branches/unicode_buf/teraterm/ttpmacro/fileread.cpp
===================================================================
--- branches/unicode_buf/teraterm/ttpmacro/fileread.cpp	2019-12-07 04:13:25 UTC (rev 8433)
+++ branches/unicode_buf/teraterm/ttpmacro/fileread.cpp	2019-12-09 14:39:25 UTC (rev 8434)
@@ -195,6 +195,40 @@
 
 /**
  *	\x83t\x83@\x83C\x83\x8B\x82\xF0\x83\x81\x83\x82\x83\x8A\x82ɓǂݍ\x9E\x82\xDE
+ *	\x92\x86\x90g\x82\xCDwchar_t\x82ɕϊ\xB7\x82\xB3\x82\xEA\x82\xE9
+ *
+ *	@param[out]	*_len	\x83T\x83C\x83Y(\x8DŌ\xE3\x82ɕt\x89\xC1\x82\xB3\x82\xEA\x82\xE9"\0"\x82\xF0\x8A܂\xDE)
+ *						NULL\x82̂Ƃ\xAB\x82͒\xB7\x82\xB3\x82\xF0\x95Ԃ\xB3\x82Ȃ\xA2
+ *	@retval		\x83t\x83@\x83C\x83\x8B\x82̒\x86\x90g\x82ւ̃|\x83C\x83\x93\x83^(\x8Eg\x97p\x8C\xE3free()\x82\xB7\x82邱\x82\xC6)
+ *				NULL=\x83G\x83\x89\x81[
+ */
+wchar_t *LoadFileWW(const wchar_t *FileName, size_t *_len)
+{
+	if (_len != NULL) {
+		*_len = 0;
+	}
+	FILE *fp = _wfopen(FileName, L"rb");
+	if (fp == NULL) {
+		return NULL;
+	}
+	char *u8 = LoadFileU8(fp, NULL);
+	fclose(fp);
+	if (u8 == NULL) {
+		return NULL;
+	}
+	wchar_t *u16 = ToWcharU8(u8);
+	free(u8);
+	if (u16 == NULL) {
+		return NULL;
+	}
+	if (_len != NULL) {
+		*_len = wcslen(u16);
+	}
+	return u16;
+}
+
+/**
+ *	\x83t\x83@\x83C\x83\x8B\x82\xF0\x83\x81\x83\x82\x83\x8A\x82ɓǂݍ\x9E\x82\xDE
  *	\x92\x86\x90g\x82\xCDANSI Codepage\x82ɕϊ\xB7\x82\xB3\x82\xEA\x82\xE9
  *
  *	@param[out]	*_len	\x83T\x83C\x83Y(\x8DŌ\xE3\x82ɕt\x89\xC1\x82\xB3\x82\xEA\x82\xE9"\0"\x82\xF0\x8A܂\xDE)

Modified: branches/unicode_buf/teraterm/ttpmacro/fileread.h
===================================================================
--- branches/unicode_buf/teraterm/ttpmacro/fileread.h	2019-12-07 04:13:25 UTC (rev 8433)
+++ branches/unicode_buf/teraterm/ttpmacro/fileread.h	2019-12-09 14:39:25 UTC (rev 8434)
@@ -34,6 +34,7 @@
 char *LoadFileU8T(const TCHAR *FileName, size_t *_len);
 wchar_t *LoadFileWA(const char *FileName, size_t *_len);
 char *LoadFileAA(const char *FileName, size_t *_len);
+wchar_t *LoadFileWW(const wchar_t *FileName, size_t *_len);
 
 #ifdef __cplusplus
 }


Ttssh2-commit メーリングリストの案内