From 2ca0db605eb50cfdf05255b79da543af6d7f64fb Mon Sep 17 00:00:00 2001 From: wjw Date: Fri, 26 Apr 2024 23:22:17 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20iconv.cs=20=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Peachpie.Library/iconv.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 From 0fb482ec67669228984c12445e7d30bc620dc74b Mon Sep 17 00:00:00 2001 From: wjw Date: Sat, 27 Apr 2024 11:26:09 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +++ 1 file changed, 3 insertions(+) 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 | From e74d6a8e9447c357417d14bee624730b5d3658d6 Mon Sep 17 00:00:00 2001 From: wjw Date: Wed, 15 May 2024 05:35:19 +0800 Subject: [PATCH 3/4] update Library.XmlDom.XMLWriter #1142 --- src/Peachpie.Library.XmlDom/XmlWriter.cs | 54 ++++++++++++++---------- 1 file changed, 32 insertions(+), 22 deletions(-) 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(" "); From ee24f7aa118b28f2ca4f7f404d915e3cdc5afb78 Mon Sep 17 00:00:00 2001 From: wjw Date: Thu, 16 May 2024 08:24:55 +0800 Subject: [PATCH 4/4] update to v1.2.0-dev --- build/build.ps1 | 2 +- build/dummy/dummy.msbuildproj | 2 +- build/update-cache.ps1 | 2 +- src/Peachpie.NET.Sdk/Peachpie.NET.Sdk.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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.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