You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2008/06/17 19:32:37 UTC

svn commit: r668763 - /wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/StringResourceStream.java

Author: ivaynberg
Date: Tue Jun 17 10:32:37 2008
New Revision: 668763

URL: http://svn.apache.org/viewvc?rev=668763&view=rev
Log:
WICKET-1704

Modified:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/StringResourceStream.java

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/StringResourceStream.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/StringResourceStream.java?rev=668763&r1=668762&r2=668763&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/StringResourceStream.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/StringResourceStream.java Tue Jun 17 10:32:37 2008
@@ -16,6 +16,10 @@
  */
 package org.apache.wicket.util.resource;
 
+import java.io.UnsupportedEncodingException;
+
+import org.apache.wicket.WicketRuntimeException;
+
 
 /**
  * A StringResourceStream is an IResource implementation for strings.
@@ -91,7 +95,22 @@
 	{
 		// WICKET-1705: we cannot use string.length() because we need number of bytes rather then
 		// number of characters
-		return string.toString().getBytes().length;
+		if (getCharset() != null)
+		{
+			try
+			{
+				return getString().getBytes(getCharset().name()).length;
+			}
+			catch (UnsupportedEncodingException e)
+			{
+				throw new WicketRuntimeException(
+					"StringResourceStream created with unsupported charset: " + getCharset().name());
+			}
+		}
+		else
+		{
+			return getString().getBytes().length;
+		}
 	}
 
 }