Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private static Map<String, String> createUnitAliases(MSBuildState state) {

private static Integer createCodePage(MSBuildState state) {
String codePage = state.getProperty("DCC_CodePage");
if (codePage == null) {
if (codePage.isEmpty()) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ class DelphiProjectFactoryTest {
private static final String CODE_PAGE_PROJECT =
"/au/com/integradev/delphi/projects/CodePageProject/Utf8.dproj";

private static final String BLANK_CODE_PAGE_PROJECT =
"/au/com/integradev/delphi/projects/CodePageProject/Blank.dproj";

private static final String PADDED_CODE_PAGE_PROJECT =
"/au/com/integradev/delphi/projects/CodePageProject/Padded.dproj";

private EnvironmentVariableProvider environmentVariableProvider;

private DelphiProject createProject(String resource) {
Expand Down Expand Up @@ -201,4 +207,18 @@ void testCodePageProject() {

assertThat(project.getCodePage()).isEqualTo(65001);
}

@Test
void testBlankCodePageProject() {
DelphiProject project = createProject(BLANK_CODE_PAGE_PROJECT);

assertThat(project.getCodePage()).isNull();
}

@Test
void testWhitespacePaddedCodePageProjectIsInvalid() {
DelphiProject project = createProject(PADDED_CODE_PAGE_PROJECT);

assertThat(project.getCodePage()).isNull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,19 @@ void testMissingProjectCodePageFallsBackToNativeCharset() {
assertThat(delphiProjectHelper.getAnsiCharset()).isEqualTo(Charset.forName("windows-1252"));
}

@Test
void testBlankProjectCodePageFallsBackToNativeCharset() {
setNativeEncoding("windows-1252");

addInputFile(PROJECTS_PATH + "CodePageProject/Utf8.dproj");
addInputFile(PROJECTS_PATH + "CodePageProject/Blank.dproj");

DelphiProjectHelper delphiProjectHelper =
new DelphiProjectHelper(settings, fs, environmentVariableProvider);

assertThat(delphiProjectHelper.getAnsiCharset()).isEqualTo(Charset.forName("windows-1252"));
}

@Test
void testAcpProjectCodePageUsesNativeCharsetWithoutConflictWhenItMatchesExplicitCodePage() {
setNativeEncoding("windows-1252");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DCC_CodePage></DCC_CodePage>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DCC_CodePage> 65001 </DCC_CodePage>
</PropertyGroup>
</Project>
Loading