| 23 | #include <iostream> |
| 24 | |
| 25 | int TestWriteToUnicodeFile(int argc, char* argv[]) |
| 26 | { |
| 27 | if (argc <= 1) |
| 28 | { |
| 29 | std::cout << "Usage: " << argv[0] << " <output file name>" << std::endl; |
| 30 | return EXIT_FAILURE; |
| 31 | } |
| 32 | |
| 33 | const char* tdir = |
| 34 | vtkTestUtilities::GetArgOrEnvOrDefault("-T", argc, argv, "VTK_TEMP_DIR", "Testing/Temporary"); |
| 35 | std::string tempDir = tdir; |
| 36 | delete[] tdir; |
| 37 | if (tempDir.empty()) |
| 38 | { |
| 39 | std::cout << "Could not determine temporary directory.\n"; |
| 40 | return EXIT_FAILURE; |
| 41 | } |
| 42 | |
| 43 | tempDir = tempDir + "/" + |
| 44 | "\xc3\xba\xce\xae\xd1\x97\xc3\xa7\xe1\xbb\x99\xe2\x82\xab\xe2\x84\xae"; // u8"úήїçộ₫℮" |
| 45 | if (!vtksys::SystemTools::FileExists(tempDir)) |
| 46 | { |
| 47 | vtksys::SystemTools::MakeDirectory(tempDir); |
| 48 | } |
| 49 | |
| 50 | std::string filename = tempDir + "/" + "\xef\xbd\xb7\xef\xbe\x80"; // u8"キタ" |
| 51 | filename.append(argv[1]); |
| 52 | size_t dotpos = filename.find_last_of('.'); |
| 53 | if (dotpos == std::string::npos) |
| 54 | { |
| 55 | std::cout << "Could not determine file extension.\n"; |
| 56 | return EXIT_FAILURE; |
| 57 | } |
| 58 | std::string fileext = filename.substr(dotpos + 1); |
| 59 | filename.insert(dotpos, "\xea\x92\x84"); // u8"ꒄ" |
| 60 | |
| 61 | int extent[6] = { 0, 99, 0, 99, 0, 0 }; |
| 62 | vtkSmartPointer<vtkImageCanvasSource2D> imageSource = |
| 63 | vtkSmartPointer<vtkImageCanvasSource2D>::New(); |
| 64 | imageSource->SetExtent(extent); |
| 65 | imageSource->SetScalarTypeToUnsignedChar(); |
| 66 | imageSource->SetNumberOfScalarComponents(3); |
| 67 | imageSource->SetDrawColor(127, 45, 255); |
| 68 | imageSource->FillBox(0, 99, 0, 99); |
| 69 | imageSource->SetDrawColor(255, 255, 255); |
| 70 | imageSource->FillBox(40, 70, 20, 50); |
| 71 | imageSource->Update(); |
| 72 | |
| 73 | vtkSmartPointer<vtkImageCast> filter = vtkSmartPointer<vtkImageCast>::New(); |
| 74 | filter->SetOutputScalarTypeToUnsignedChar(); |
| 75 | filter->SetInputConnection(imageSource->GetOutputPort()); |
| 76 | filter->Update(); |
| 77 | |
| 78 | vtkSmartPointer<vtkImageWriter> writer; |
| 79 | vtkSmartPointer<vtkImageReader2> reader; |
| 80 | |
| 81 | // Delete any existing files to prevent false failures |
| 82 | if (!vtksys::SystemTools::FileExists(filename)) |
nothing calls this directly
no test coverage detected