我用VS编写的记事本为什么不能保存中文?保存再用它打开就是乱码,用win7自带的没有问题,求帮助。

u012983870 2013-11-28 03:26:10
用win7自带的保存类型设为Unicode 也没用,暂时只能用文件下面的功能,打开保存什么的,其他的还没写。
求帮忙下载页:
http://download.csdn.net/detail/u012983870/6625523
...全文
255 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2013-11-28
  • 打赏
  • 举报
回复
In Visual C++ 2005, fopen supports Unicode file streams. A flag specifying the desired encoding may be passed to fopen when opening a new file or overwriting an existing file, like this: fopen("newfile.txt", "rw, ccs=<encoding>"); Allowed values of the encoding include UNICODE, UTF-8, and UTF16-LE. If the file is already in existence and is opened for reading or appending, the Byte Order Mark (BOM) is used to determine the correct encoding. It is not necessary to specify the encoding with a flag. In fact, the flag will be ignored if it conflicts with the type of the file as indicated by the BOM. The flag is only used when no BOM is present or if the file is a new file. The following table summarizes the modes used in for various flags given to fopen and Byte Order Marks used in the file. Flag No BOM (or new file) BOM: UTF-8 BOM: UTF-16 UNICODE ANSI UTF-8 UTF-16LE UTF-8 UTF-8 UTF-8 UTF-16LE UTF-16LE UTF-16LE UTF-8 UTF-16LE If mode is "a, ccs=<encoding>", fopen will first try to open the file with both read and write access. If it succeeds, it will read the BOM to determine the encoding for this file; however, if it fails, it will use the default encoding for the file. In either case, fopen will then re-open the file with write-only access. (This applies to mode a only, not a+.)
赵4老师 2013-11-28
  • 打赏
  • 举报
回复
fprintf, fwprintf Print formatted data to a stream. int fprintf( FILE *stream, const char *format [, argument ]...); int fwprintf( FILE *stream, const wchar_t *format [, argument ]...); Function Required Header Compatibility fprintf <stdio.h> ANSI, Win 95, Win NT fwprintf <stdio.h> or <wchar.h> ANSI, Win 95, Win NT For additional compatibility information, see Compatibility in the Introduction. Libraries LIBC.LIB Single thread static library, retail version LIBCMT.LIB Multithread static library, retail version MSVCRT.LIB Import library for MSVCRT.DLL, retail version Return Value fprintf returns the number of bytes written. fwprintf returns the number of wide characters written. Each of these functions returns a negative value instead when an output error occurs. Parameters stream Pointer to FILE structure format Format-control string argument Optional arguments Remarks fprintf formats and prints a series of characters and values to the output stream. Each function argument (if any) is converted and output according to the corresponding format specification in format. For fprintf, the format argument has the same syntax and use that it has in printf. fwprintf is a wide-character version of fprintf; in fwprintf, format is a wide-character string. These functions behave identically otherwise. Generic-Text Routine Mappings TCHAR.H Routine _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined _ftprintf fprintf fprintf fwprintf For more information, see Format Specifcations. Example /* FPRINTF.C: This program uses fprintf to format various * data and print it to the file named FPRINTF.OUT. It * then displays FPRINTF.OUT on the screen using the system * function to invoke the operating-system TYPE command. */ #include <stdio.h> #include <process.h> FILE *stream; void main( void ) { int i = 10; double fp = 1.5; char s[] = "this is a string"; char c = '\n'; stream = fopen( "fprintf.out", "w" ); fprintf( stream, "%s%c", s, c ); fprintf( stream, "%d\n", i ); fprintf( stream, "%f\n", fp ); fclose( stream ); system( "type fprintf.out" ); } Output this is a string 10 1.500000 Stream I/O Routines See Also _cprintf, fscanf, sprintf

3,882

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧