Opened 8 years ago

Closed 7 years ago

#482 closed Bugs (fixed)

Unicode not throughout PHPEclipse

Reported by: guradia Owned by: nobody
Priority: 5 Milestone: 1.2.0
Component: PHP Editor Version: 1.2.0-nightly
Keywords: Cc:

Description (last modified by ed_mann)

Using Unicode (UTF-8) inside Files is not an Issue. PHP
(with mbstring) and PHPEclipse does allow this quite
happly within:
- Function Names (not as first Char, just about ISO-8859-1)
- Variables/Props (not as first Char, just about
ISO-8859-1)
- Let it show up in the Outline
- Full Unicode in Comments and Strings

But what PHPEclise does not throughfully support:
- Showing these Names in the AutoCompletion

PHPEclispe either fails to list them or mangles the
Special-Chars with the typical UTF-8-to-ISO-8859-1-result.

Since the PHP-Editor, Eclipse itself and the Outline do
support Unicode without any problem, i hope this won't
be a big issue.

Change History (4)

comment:1 Changed 8 years ago by toshihiro

Logged In: YES 
user_id=1527096

### Eclipse Workspace Patch 1.0
#P net.sourceforge.phpeclipse
Index: src/net/sourceforge/phpdt/internal/corext/phpdoc/PHPDocUtil.java
===================================================================
RCS file: /cvsroot/phpeclipse/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/phpdoc/PHPDocUtil.java,v
retrieving revision 1.4
diff -u -r1.4 PHPDocUtil.java
--- src/net/sourceforge/phpdt/internal/corext/phpdoc/PHPDocUtil.java	2 Sep 2004 18:32:40 -0000	1.4
+++ src/net/sourceforge/phpdt/internal/corext/phpdoc/PHPDocUtil.java	24 Jul 2006 22:56:25 -0000
@@ -1,8 +1,15 @@
 package net.sourceforge.phpdt.internal.corext.phpdoc;
 
+import java.io.FileInputStream;
 import java.io.FileReader;
 import java.io.IOException;
+import java.io.InputStreamReader;
 
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.builder.PHPIdentifierLocation;
 
 /**
@@ -18,7 +25,6 @@
    * @param location
    */
   public static void appendPHPDoc(StringBuffer hoverInfoBuffer, String filename, PHPIdentifierLocation location) {
-    FileReader phpFileReader;
     hoverInfoBuffer.append(location.toString());
     hoverInfoBuffer.append(" - <b>");
     try {
@@ -27,7 +33,16 @@
 
       //	read the phpdoc for the function
       if (location.getPHPDocOffset() >= 0) {
-        phpFileReader = new FileReader(filename);
+      	String encoding ="";
+        IFile file = PHPeclipsePlugin.getWorkspace().getRoot().getFileForLocation(new Path(filename));
+        if (file != null) {
+            try {
+                encoding = file.getCharset();
+            } catch (CoreException e) {
+            	// do nothing
+            }
+        }
+        InputStreamReader phpFileReader = new InputStreamReader(new FileInputStream(filename), encoding);
         char[] phpDocDeclarationCharArray = new char[location.getPHPDocLength()];
         phpFileReader.skip(location.getPHPDocOffset());
         phpFileReader.read(phpDocDeclarationCharArray, 0, location.getPHPDocLength());
@@ -43,7 +58,6 @@
   }
 
   public static String getUsage(String filename, PHPIdentifierLocation location) {
-    FileReader phpFileReader;
     String usage = location.getUsage();
     if (usage!=null) {
     	return usage;
@@ -51,7 +65,17 @@
     usage = "";
     try {
 			
-      phpFileReader = new FileReader(filename);
+    	String encoding ="";
+        IFile file = PHPeclipsePlugin.getWorkspace().getRoot().getFileForLocation(new Path(filename));
+        if (file != null) {
+            try {
+                encoding = file.getCharset();
+            } catch (CoreException e) {
+            	// do nothing
+            }
+        }
+        InputStreamReader phpFileReader = new InputStreamReader(new FileInputStream(filename), encoding);
+
       // read the function declaration
       if (location.getOffset() >= 0 && (location.isMethod() || location.isConstructor() || location.isFunction() || location.isDefine())) {
         char[] functionDeclarationCharArray = new char[256];

comment:2 Changed 8 years ago by toshihiro

Logged In: YES 
user_id=1527096

### Eclipse Workspace Patch 1.0
#P net.sourceforge.phpeclipse
Index: src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java
===================================================================
RCS file: /cvsroot/phpeclipse/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java,v
retrieving revision 1.26
diff -u -r1.26 IdentifierIndexManager.java
--- src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java	10 Jan 2006 18:14:38 -0000	1.26
+++ src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java	24 Jul 2006 22:55:10 -0000
@@ -445,7 +445,7 @@
     LineCreator lineCreator = createLineCreator();
     try {
       addInputStream(new BufferedInputStream(fileToParse.getContents()), fileToParse.getProjectRelativePath().toString(),
-          lineCreator);
+          lineCreator, fileToParse.getCharset());
     } catch (CoreException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
@@ -457,12 +457,12 @@
    * @param lineCreator
    * @throws CoreException
    */
-  public void addInputStream(InputStream stream, String filePath, LineCreator lineCreator) throws CoreException {
+  public void addInputStream(InputStream stream, String filePath, LineCreator lineCreator, String charset) throws CoreException {
     try {
       StringBuffer lineBuffer = new StringBuffer();
       lineBuffer.append(filePath);
       int lineLength = lineBuffer.length();
-      lineCreator.parseIdentifiers(Util.getInputStreamAsCharArray(stream, -1, null), lineBuffer);
+      lineCreator.parseIdentifiers(Util.getInputStreamAsCharArray(stream, -1, charset), lineBuffer);
       //      if (lineLength != lineBuffer.length()) {
       // always add the file for Open Include Action
       addLine(lineBuffer.toString());

comment:3 Changed 7 years ago by ed_mann

  • billable set to 0
  • Description modified (diff)
  • Milestone set to 1.2.x
  • os_platform set to Linux
  • Version changed from None to 1.2.0-nightly

comment:4 Changed 7 years ago by ed_mann

  • Resolution changed from None to fixed
  • Status changed from assigned to closed

Checking the code this has been applied. So i am closing this request.

Note: See TracTickets for help on using tickets.