Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-4678

libhdfs casts Japanese character incorrectly to Java API

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.1.2
    • None
    • libhdfs
    • None
    • Platform:    Linux64
      Locale:    Japanese (ja_JP.UTF-8)

    Description

      put a local file with Japanese characters to hdfs,
      while browsing it in hdfs, it cannot be recognized.

      here is the test.c

      #include "hdfs.h"
      #include <stdio.h>
      #include <locale.h>

      int main(int argc, char **argv) {
      if(!setlocale(LC_CTYPE, "ja_JP"))

      { printf("Can not set locale type\n"); }

      printf("0\n");
      hdfsFS fs = hdfsConnect("localhost", 9000);
      printf("1\n");
      const char* writePath = "/tmp/\xF0\xA0\x80\x8B.txt";
      printf("2\n");
      hdfsFile writeFile = hdfsOpenFile(fs, writePath, O_WRONLY|O_CREAT, 0, 0, 0);
      if(!writeFile)

      { fprintf(stderr, "Failed to open %s for writing!\n", writePath); exit(-1); }

      char* buffer = "Hello, World! \xF0\xA0\x80\x8B";
      tSize num_written_bytes = hdfsWrite(fs, writeFile, (void*)buffer, strlen(buffer)+1);
      if (hdfsFlush(fs, writeFile))

      { fprintf(stderr, "Failed to 'flush' %s\n", writePath); exit(-1); }

      printf("3\n");
      hdfsCloseFile(fs, writeFile);
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            xujiqiu Jiqiu
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: