diff --git a/cpp/src/arrow/io/file_test.cc b/cpp/src/arrow/io/file_test.cc index 81ae716ef67..17d8e5f3727 100644 --- a/cpp/src/arrow/io/file_test.cc +++ b/cpp/src/arrow/io/file_test.cc @@ -115,7 +115,25 @@ TEST_F(TestFileOutputStream, FileNameWideCharConversionRangeException) { ASSERT_RAISES(Invalid, ReadableFile::Open(file_name)); } -// TODO add a test with a valid utf-8 filename +TEST_F(TestFileOutputStream, FileNameValidUtf8) { + // Test that file operations work with UTF-8 filenames (Korean + emoji). + // On Windows, PlatformFilename::FromString() converts UTF-8 strings to wide strings. + // On Unix, filenames are treated as opaque byte strings. + std::string utf8_file_name = "test_file_한국어_😀.txt"; + std::string utf8_path = TempFile(utf8_file_name); + + ASSERT_OK_AND_ASSIGN(auto file, FileOutputStream::Open(utf8_path)); + const char* data = "test content"; + ASSERT_OK(file->Write(data, strlen(data))); + ASSERT_OK(file->Close()); + + // Verify we can read it back + ASSERT_OK_AND_ASSIGN(auto readable_file, ReadableFile::Open(utf8_path)); + ASSERT_OK_AND_ASSIGN(auto buffer, readable_file->ReadAt(0, strlen(data))); + ASSERT_EQ(std::string(reinterpret_cast(buffer->data()), buffer->size()), + std::string(data)); + ASSERT_OK(readable_file->Close()); +} #endif TEST_F(TestFileOutputStream, DestructorClosesFile) {