나는이 질문을하기 전에 물었고 대답을 얻었다. 하지만 지금은 다른 문제에 직면하고 있습니다. 파일 이름이 있습니다. 이름은 다음과 같습니다. <~ '‡ ™ ...... 히브리어 값을 얻기 위해 디코드하고 싶습니다. 내가 사용하는 코드 :라틴 문자를 히브리어로 변환합니다.
Encoding latinEncoding = Encoding.GetEncoding("Windows-1252");
Encoding hebrewEncoding = Encoding.GetEncoding(862);
byte[] latinBytes = latinEncoding.GetBytes(str);
string hebrewString = hebrewEncoding.GetString(latinBytes);
이 코드는 작동 잘하지만 잘되지. 나는 몇몇 문자가 "?"로 디코딩된다는 것을 의미한다. 그들의 히브리어 가치 대신에.
그래서이 코드로 주어진 이름을 디코딩하면 나에게 "כטטס חשבונו?" "כרטסת חשבונות"대신. 그 문제가있는 히브리어 문자는 다음과 같습니다 : ך, ל, מ, ת. 다른 모든 것들은 훌륭하게 해독됩니다.
해결책을 찾았지 만 가능한 경우이를 피하고 싶습니다. 해결 방법은 주어진 문자열을 파일에 저장 한 다음 862 인코딩으로 파일을 다시 읽는 것입니다. 코드는 다음과 같습니다.
string str = "‹˜ˆ‘ ‡™……";
// Get uniqe file name based on current date and time
reportFileName = DateTime.Now.ToString().Replace("/", "-").Replace(":", ";");
// set the file path
string repFilePath = parametersFolder + @"\" + reportFileName;
// save the value to a file with 1255 encoding
File.WriteAllText(repFilePath, str, Encoding.GetEncoding(1255));
// read the value back with 862 encoding
string s = File.ReadAllText(repFilePath, Encoding.GetEncoding(862));
// Delete the file
File.Delete(repFilePath);
// Save the value to a variable.
generatedFileName = s;
포럼 사이트와 달리 "감사"또는 "도움을 주신 데 대한 감사"또는 [so]의 서명은 사용하지 않습니다. "[안녕하세요, '고마워,'태그 라인 및 인사말을 게시물에서 삭제해야합니까?] (http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be 참조) - 게시물에서 제외) –
@ JohnSaunders 좋아, 다음 번에 기억하겠습니다. 내 질문에 대한 답변은 무엇입니까? – subirshan
이름을 ** <~ ' ‡ ™ ...... ...... ** 올바른 결과를 얻으려면 ** <~ 'š ™ ™ ...... š **입니다. 또한 회선의 예외로 인해 내 컴퓨터에서 회피가 전혀 작동하지 않습니다 –