diff --git a/README.md b/README.md
index 9621e9710c..ca1724ac77 100644
--- a/README.md
+++ b/README.md
@@ -19,6 +19,9 @@
[
](https://www.dotnetfoundation.org/)
PeachPie is a member project of the [.NET Foundation](https://www.dotnetfoundation.org/about).
+## 本分支是为修复汉字的兼容性
+ > This branch is to fix the compatibility of Chinese characters
+
## Continuous Integration
| Service | Platform | Build Status |
diff --git a/build/build.ps1 b/build/build.ps1
index b2c5e6813e..903ce38630 100644
--- a/build/build.ps1
+++ b/build/build.ps1
@@ -1,5 +1,5 @@
Param(
- [string]$version = "1.0.0-dev",
+ [string]$version = "1.2.0-dev",
[string]$config = "Debug"
)
diff --git a/build/dummy/dummy.msbuildproj b/build/dummy/dummy.msbuildproj
index a0a5277f52..260a76027e 100644
--- a/build/dummy/dummy.msbuildproj
+++ b/build/dummy/dummy.msbuildproj
@@ -1,4 +1,4 @@
-
+
net50
diff --git a/build/update-cache.ps1 b/build/update-cache.ps1
index a323198be5..a53d655d72 100644
--- a/build/update-cache.ps1
+++ b/build/update-cache.ps1
@@ -3,7 +3,7 @@
# Note: In prior to use Powershell scripts, it might be needed to run:
# powershell Set-ExecutionPolicy Unrestricted -Scope CurrentUser
-param([string]$version = "1.0.0", [string]$suffix = "dev")
+param([string]$version = "1.2.0", [string]$suffix = "dev")
# We suppose the global package source is in the default location
$rootDir = [System.IO.Path]::GetFullPath("$PSScriptRoot/..")
diff --git a/src/Peachpie.Library.XmlDom/XmlWriter.cs b/src/Peachpie.Library.XmlDom/XmlWriter.cs
index cf2127fbe2..279eb12eba 100644
--- a/src/Peachpie.Library.XmlDom/XmlWriter.cs
+++ b/src/Peachpie.Library.XmlDom/XmlWriter.cs
@@ -16,6 +16,7 @@ namespace Peachpie.Library.XmlDom
[PhpType(PhpTypeAttribute.InheritName), PhpExtension("xmlwriter")]
public class XMLWriter : IDisposable
{
+
#region Constants
private protected const string DefaultXmlVersion = "1.0";
@@ -23,8 +24,9 @@ public class XMLWriter : IDisposable
#endregion
#region Fields and properties
+ XmlTextWriter _writer;
- System.Xml.XmlWriter _writer;
+ //wjw - System.Xml.XmlWriter _writer;
MemoryStream _memoryStream;
PhpStream _uriPhpStream;
@@ -212,7 +214,7 @@ public bool endDtd()
_state.Pop();
// Closes dtd section.
- string end = _writer.Settings.Indent ? _writer.Settings.NewLineChars : "";
+ string end = _writer.Formatting == Formatting.Indented ? DefaultSettings.NewLineChars : ""; // string end = _writer.Settings.Indent ? _writer.Settings.NewLineChars : "";
end += _dtdStart ? ">" : "]>";
_dtdStart = false;
@@ -292,7 +294,9 @@ public bool openMemory(Context ctx)
{
Clear();
_memoryStream = new MemoryStream();
- _writer = System.Xml.XmlWriter.Create(_memoryStream, DefaultSettings);
+ _writer = new XmlTextWriter(_memoryStream, DefaultSettings.Encoding); //_writer = System.Xml.XmlWriter.Create(_memoryStream, DefaultSettings);
+ _writer.Formatting = DefaultSettings.Indent ? Formatting.Indented : Formatting.None;
+
ctx.RegisterDisposable(this);
return true;
}
@@ -309,7 +313,7 @@ public bool openUri(Context ctx, string uri)
try
{
- _writer = System.Xml.XmlWriter.Create(_uriPhpStream.RawStream, DefaultSettings);
+ _writer = new XmlTextWriter(_uriPhpStream.RawStream, DefaultSettings.Encoding); //_writer = System.Xml.XmlWriter.Create(_uriPhpStream.RawStream, DefaultSettings);
ctx.RegisterDisposable(this);
return true;
}
@@ -340,13 +344,13 @@ public bool setIndentString(string indentString)
return false;
// The settings is read-only, but we can create a new xmlwriter if the current xmlwriter haven't written anything yet.
- var settings = _writer.Settings.Clone();
+ var settings =DefaultSettings.Clone(); // var settings = _writer.Settings.Clone();
settings.IndentChars = indentString;
if (_uriPhpStream == null)
- _writer = XmlWriter.Create(_memoryStream, settings);
+ _writer = new XmlTextWriter(_memoryStream, settings.Encoding); //_writer = XmlWriter.Create(_memoryStream, settings);
else
- _writer = XmlWriter.Create(_uriPhpStream.RawStream, settings);
+ _writer = new XmlTextWriter(_uriPhpStream.RawStream, settings.Encoding); //_writer = XmlWriter.Create(_uriPhpStream.RawStream, settings);
return true;
}
@@ -357,13 +361,13 @@ public bool setIndent(bool indent)
return false;
// The settings is read-only, but we can create a new xmlwriter if the current xmlwriter haven't written anything yet.
- var settings = _writer.Settings.Clone();
+ var settings = DefaultSettings.Clone(); // var settings = _writer.Settings.Clone();
settings.Indent = indent;
if (_uriPhpStream == null)
- _writer = XmlWriter.Create(_memoryStream, settings);
+ _writer = new XmlTextWriter(_memoryStream, settings.Encoding); //_writer = XmlWriter.Create(_memoryStream, settings);
else
- _writer = XmlWriter.Create(_uriPhpStream.RawStream, settings);
+ _writer = new XmlTextWriter(_uriPhpStream.RawStream, settings.Encoding); //_writer = XmlWriter.Create(_uriPhpStream.RawStream, settings);
return true;
}
@@ -422,16 +426,16 @@ public bool startDocument(string version = DefaultXmlVersion, string encoding =
if (string.IsNullOrEmpty(standalone))
{
bool res = CheckedCall(() => _writer.WriteStartDocument());
- if (!_writer.Settings.Indent) // Php writes a new line character after prolog.
- res &= CheckedCall(() => _writer.WriteRaw(_writer.Settings.NewLineChars));
+ if (_writer.Formatting==Formatting.None) // if (!_writer.Settings.Indent) // Php writes a new line character after prolog.
+ res &= CheckedCall(() => _writer.WriteRaw(DefaultSettings.NewLineChars)); //res &= CheckedCall(() => _writer.WriteRaw(_writer.Settings.NewLineChars));
return res;
}
else
{
bool res = CheckedCall(() => _writer.WriteStartDocument(standalone == "yes"));
- if (!_writer.Settings.Indent) // Php writes a new line character after prolog.
- res &= CheckedCall(() => _writer.WriteRaw(_writer.Settings.NewLineChars));
+ if (_writer.Formatting == Formatting.None) // if (!_writer.Settings.Indent) // Php writes a new line character after prolog.
+ res &= CheckedCall(() => _writer.WriteRaw(DefaultSettings.NewLineChars)); // res &= CheckedCall(() => _writer.WriteRaw(_writer.Settings.NewLineChars));
return res;
}
@@ -476,7 +480,8 @@ public bool startDtdEntity(string name, bool isparam)
public bool startDtd(string qualifiedName, string publicId = null, string systemId = null)
{
if (_state.Count != 0 || // DTD can be only placed in default section and prolog.
- (_writer.Settings.ConformanceLevel == ConformanceLevel.Document && _writer.WriteState != WriteState.Prolog && _writer.WriteState != WriteState.Start))
+ //(_writer.Settings.ConformanceLevel == ConformanceLevel.Document && _writer.WriteState != WriteState.Prolog && _writer.WriteState != WriteState.Start))
+ (DefaultSettings.ConformanceLevel == ConformanceLevel.Document && _writer.WriteState != WriteState.Prolog && _writer.WriteState != WriteState.Start))
{
PhpException.Throw(PhpError.Warning, Resources.XmlWritterDtdInProlog);
return false;
@@ -491,9 +496,11 @@ public bool startDtd(string qualifiedName, string publicId = null, string system
// Makes a doctype
string doctype = $"";
@@ -740,9 +750,9 @@ private void CheckDtdStartHelper()
_dtdStart = false;
}
- if (_writer.Settings.Indent)
+ if (_writer.Formatting==Formatting.Indented) //if (_writer.Settings.Indent)
{
- _writer.WriteRaw(_writer.Settings.NewLineChars);
+ _writer.WriteRaw(DefaultSettings.NewLineChars); //_writer.WriteRaw(_writer.Settings.NewLineChars);
if (_state.Count != 0 && _state.Peek() == State.DTD)
_writer.WriteRaw(" ");
diff --git a/src/Peachpie.Library/iconv.cs b/src/Peachpie.Library/iconv.cs
index b035a50348..1527da1a13 100644
--- a/src/Peachpie.Library/iconv.cs
+++ b/src/Peachpie.Library/iconv.cs
@@ -15,6 +15,20 @@ namespace Pchp.Library
[PhpExtension("iconv", Registrator = typeof(PhpIconv.Registrator))]
public static class PhpIconv
{
+ ///
+ /// wjw add 2024-04-08 增加一个静态构造,汉字编码支持 18行
+ ///
+ static PhpIconv()
+ {
+ try
+ {
+ Encoding.GetEncoding("GBK");
+ }
+ catch (Exception)
+ {
+ Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
+ }
+ }
#region IconvConfig, Options
sealed class IconvConfig : IPhpConfiguration
diff --git a/src/Peachpie.NET.Sdk/Peachpie.NET.Sdk.csproj b/src/Peachpie.NET.Sdk/Peachpie.NET.Sdk.csproj
index 67eed08357..623ebcc0f9 100644
--- a/src/Peachpie.NET.Sdk/Peachpie.NET.Sdk.csproj
+++ b/src/Peachpie.NET.Sdk/Peachpie.NET.Sdk.csproj
@@ -3,7 +3,7 @@
Peachpie.NET.Sdk
- 1.0.0-dev
+ 1.2.0-dev
true
false
false