Difference between revisions of "Lazarus with FPC3.0 without UTF-8 mode"

From Free Pascal wiki
Jump to navigationJump to search
m
(file encoding + simple example added)
Line 3: Line 3:
  
 
To disable the new UTF-8 mode, '''-dDisableUTF8RTL''' must be defined in project options, "Additions and Overrides" page. There is a button "Use system encoding" to help adding it with one click.
 
To disable the new UTF-8 mode, '''-dDisableUTF8RTL''' must be defined in project options, "Additions and Overrides" page. There is a button "Use system encoding" to help adding it with one click.
This way it affects both the project and all its dependent packages, including LazUtils which contains the relevant code.
+
This way it affects both the project and all its dependent packages, including LazUtils which contains the relevant code. If you use strings with codepoints > 127 in your project, you have to change the file encoding to the system encoding too.
  
 
Many of the problems are counter-intuitive. [[user:Bart|Bart]] has collected some reported issues under a meta-issue. It includes issues in FPC.
 
Many of the problems are counter-intuitive. [[user:Bart|Bart]] has collected some reported issues under a meta-issue. It includes issues in FPC.
Line 9: Line 9:
  
 
ToDo: Explain each problem and a solution for it ...
 
ToDo: Explain each problem and a solution for it ...
 +
 +
= Simple Example =
 +
 +
* create a ''New Project'' -> ''Simple Program''
 +
* activate the ''-dDisableUTF8RTL'' mode with ''Project Options ...'' -> ''Compiler Options'' -> ''Additions and Overrides'' -> click on ''Use system encoding''
 +
* change the file encoding: ''Source Editor'' -> mouse rightclick -> ''File Settings'' -> ''Encoding'' -> take your system encoding (for that example take 1252) and confirm
 +
 +
Now you are able to build a project without UTF8 dependences.
 +
 +
Write something in your source editor:
 +
<syntaxhighlight>
 +
program project1;
 +
 +
{$mode objfpc}{$H+}
 +
{$codepage cp1252}
 +
 +
var
 +
  test: String;
 +
 +
begin
 +
  test := 'ÄÖÜ';
 +
  writeln(test);
 +
  readln;
 +
end.   
 +
</syntaxhighlight>
 +
 +
Start your program.
  
  
 
[[Category:FPC 3.0+ stuff]]
 
[[Category:FPC 3.0+ stuff]]

Revision as of 14:57, 30 October 2015

This page explains the problems and their possible solutions when using Lazarus with FPC 3.0+ but without the new UTF-8 mode. It may be needed when big parts of program code depend on system codepage.

To disable the new UTF-8 mode, -dDisableUTF8RTL must be defined in project options, "Additions and Overrides" page. There is a button "Use system encoding" to help adding it with one click. This way it affects both the project and all its dependent packages, including LazUtils which contains the relevant code. If you use strings with codepoints > 127 in your project, you have to change the file encoding to the system encoding too.

Many of the problems are counter-intuitive. Bart has collected some reported issues under a meta-issue. It includes issues in FPC.

ToDo: Explain each problem and a solution for it ...

Simple Example

  • create a New Project -> Simple Program
  • activate the -dDisableUTF8RTL mode with Project Options ... -> Compiler Options -> Additions and Overrides -> click on Use system encoding
  • change the file encoding: Source Editor -> mouse rightclick -> File Settings -> Encoding -> take your system encoding (for that example take 1252) and confirm

Now you are able to build a project without UTF8 dependences.

Write something in your source editor:

program project1;

{$mode objfpc}{$H+}
{$codepage cp1252}

var
  test: String;

begin
  test := 'ÄÖÜ';
  writeln(test);
  readln;
end.

Start your program.