Char
StreamWriter
public:
virtual void Write (
array<wchar_t>^ buffer,
int index,
int count
)
cat sw_test.cpp
using namespace System;
using namespace System::IO;
int main(){
String^ path = ".\\MyTest.txt";
if ( !File::Exists( path ) ) {
StreamWriter^ sw = File::CreateText( path );
try {
sw->WriteLine( "Header ====" );
}
finally {
if ( sw )
delete (IDisposable^)sw;
}
}
StreamWriter^ sw = File::AppendText( path );
try {
sw->WriteLine( "Contents 1" );
sw->WriteLine( "Contents 2" );
sw->WriteLine( "Contents 3" );
sw->WriteLine( "Contents 4" );
sw->WriteLine( "日本語SJIS" );
sw->WriteLine( "Contents 5" ); } finally { if ( sw ) delete (IDisposable^)sw;
} StreamReader^ sr = File::OpenText( path ); try { String^ s = ""; while ( s = sr->ReadLine()
) { Console::WriteLine( s ); } } finally { if ( sr ) delete (IDisposable^)sr; }
}
cat makefile
TARGET=sw_test
.PHONY: all test mmm clean
.SUFFIXES: .obj .exe
OBJS=$(TARGET).obj
all: $(TARGET).exe
$(TARGET).exe: $(OBJS)
link $(OBJS)
$(TARGET).obj: $(TARGET).cpp
.cpp.obj:
cl -c -clr $<
test: $(TARGET).exe
./$(TARGET).exe
clean:
@-rm $(TARGET).exe *.o *~ $(TARGET).exe.manifest 1>/dev/null 2>&1
@-rm MyTest.txt 1>/dev/null 2>&1
@-rm $(TARGET).sjis 1>/dev/null 2>&1
@-rm $(TARGET).euc 1>/dev/null 2>&1
@-rm $(TARGET).utf8 1>/dev/null 2>&1
sjis:
cat $(TARGET).cpp | nkf -s > $(TARGET).sjis
cp $(TARGET).sjis $(TARGET).cpp
file $(TARGET).cpp
euc:
cat $(TARGET).cpp | nkf -e > $(TARGET).euc
cp $(TARGET).euc $(TARGET).cpp
file $(TARGET).cpp
utf8:
cat $(TARGET).cpp | nkf -w0 > $(TARGET).utf8
cp $(TARGET).utf8 $(TARGET).cpp
file $(TARGET).cpp
mmm:
cat $(TARGET).cpp
@echo
cat makefile
html:
cat /dev/clipboard | code2html.exe | unix2dos