Skip to content

Commit

Permalink
Bug 1447: UTF-16 script files cannot be loaded
Browse files Browse the repository at this point in the history
https://winscp.net/tracker/1447

Source commit: 22dccaf23b6e5c38838ae3db5cc9e43c936a670a
  • Loading branch information
martinprikryl committed Jan 27, 2018
1 parent 5dea2f0 commit ec3e821
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion source/core/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3478,7 +3478,16 @@ UnicodeString __fastcall AssemblyNewClassInstanceEnd(TAssemblyLanguage Language,
//---------------------------------------------------------------------------
void __fastcall LoadScriptFromFile(UnicodeString FileName, TStrings * Lines)
{
Lines->LoadFromFile(ApiPath(FileName), TEncoding::UTF8);
std::auto_ptr<TFileStream> Stream(new TFileStream(ApiPath(FileName), fmOpenRead | fmShareDenyWrite));
Lines->DefaultEncoding = TEncoding::UTF8;
try
{
Lines->LoadFromStream(Stream.get());
}
catch (EEncodingError & E)
{
throw ExtException(LoadStr(TEXT_FILE_ENCODING), &E);
}
}
//---------------------------------------------------------------------------
UnicodeString __fastcall StripEllipsis(const UnicodeString & S)
Expand Down
1 change: 1 addition & 0 deletions source/resource/TextsCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@
#define CODE_CONNECT 551
#define CODE_PS_ADD_TYPE 553
#define COPY_INFO_PRESERVE_TIME_DIRS 554
#define TEXT_FILE_ENCODING 555

#define CORE_VARIABLE_STRINGS 600
#define PUTTY_BASED_ON 601
Expand Down
1 change: 1 addition & 0 deletions source/resource/TextsCore1.rc
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ BEGIN
CODE_CONNECT, "Connect"
CODE_PS_ADD_TYPE, "Load WinSCP .NET assembly"
COPY_INFO_PRESERVE_TIME_DIRS, "%s (including directories)"
TEXT_FILE_ENCODING, "The file must be in UTF-8 or UTF-16 encoding."

CORE_VARIABLE_STRINGS, "CORE_VARIABLE"
PUTTY_BASED_ON, "SSH and SCP code based on PuTTY %s"
Expand Down

0 comments on commit ec3e821

Please sign in to comment.