engine/src/PodcastUtils.cpp
branch3rded
changeset 390 d7abecc9d189
parent 343 9c56bf585696
equal deleted inserted replaced
345:702ba9ffe210 390:d7abecc9d189
   116 		
   116 		
   117 // change HTML encoded chars to unicode
   117 // change HTML encoded chars to unicode
   118 	DP("    change HTML encoded chars to unicode");
   118 	DP("    change HTML encoded chars to unicode");
   119 	startPos = str.Locate('&');
   119 	startPos = str.Locate('&');
   120 	endPos = str.Locate(';');
   120 	endPos = str.Locate(';');
   121 	while (startPos != KErrNotFound && endPos != KErrNotFound && endPos > startPos)
   121 	while (startPos != KErrNotFound && endPos != KErrNotFound && endPos > startPos && endPos < str.Length())
   122 		{
   122 		{
       
   123 //		DP2("startPos=%d, endPos=%d", startPos, endPos);
   123 		TPtrC ptr(str.Mid(startPos+1, endPos-startPos));
   124 		TPtrC ptr(str.Mid(startPos+1, endPos-startPos));
   124 		// check for whitespace
   125 		// check for whitespace
   125 		if (ptr.Locate(' ') == KErrNotFound)
   126 		if (ptr.Locate(' ') == KErrNotFound)
   126 			{
   127 			{
   127 			// numerical constant
   128 			// numerical constant
   160 				{
   161 				{
   161 				_LIT(KAmp, "amp;");
   162 				_LIT(KAmp, "amp;");
   162 				_LIT(KQuot, "quot;");
   163 				_LIT(KQuot, "quot;");
   163 				_LIT(KNbsp, "nbsp;");
   164 				_LIT(KNbsp, "nbsp;");
   164 				_LIT(KCopy, "copy;");
   165 				_LIT(KCopy, "copy;");
   165 				
   166 
   166 				// copy start of string
   167 				// copy start of string
   167 				tmp.Copy(str.Left(startPos));
   168 				tmp.Copy(str.Left(startPos));
   168 				
       
   169 				if (ptr.CompareF(KAmp) == 0)
   169 				if (ptr.CompareF(KAmp) == 0)
   170 					{
   170 					{
   171 					tmp.Append('&');
   171 					tmp.Append('&');
   172 					}
   172 					}
   173 				else if (ptr.CompareF(KQuot) == 0)
   173 				else if (ptr.CompareF(KQuot) == 0)
   180 					}
   180 					}
   181 				else if (ptr.CompareF(KCopy) == 0)
   181 				else if (ptr.CompareF(KCopy) == 0)
   182 					{
   182 					{
   183 					tmp.Append('\xA9');
   183 					tmp.Append('\xA9');
   184 					}
   184 					}
   185 				
       
   186 				// copy end of string
   185 				// copy end of string
   187 				tmp.Append(str.Mid(endPos+1));
   186 				tmp.Append(str.Mid(endPos+1));
   188 				str.Copy(tmp);
   187 				str.Copy(tmp);
   189 				}
   188 				}
   190 			}
   189 			}
   191 		
   190 		
   192 		TInt newPos = str.Mid(startPos+1).Locate('&');
   191 		if (startPos+1 <= str.Length()) {
   193 		
   192 			TInt newPos = str.Mid(startPos+1).Locate('&');
   194 		if (newPos != KErrNotFound)
   193 			if (newPos != KErrNotFound)
   195 			{
   194 				{
   196 			startPos = startPos+1 + newPos;
   195 				startPos = startPos+1 + newPos;
   197 			endPos = str.Locate(';');
   196 				endPos = str.Locate(';');
   198 			}
   197 				}
   199 		else
   198 			else
   200 			{
   199 				{
   201 			startPos = KErrNotFound;
   200 				startPos = KErrNotFound;
   202 			endPos = KErrNotFound;
   201 				endPos = KErrNotFound;
   203 			}
   202 				}
   204 		}
   203 			}
   205 		
   204 		}
   206 	CleanupStack::PopAndDestroy(tmpBuf);
   205 	CleanupStack::PopAndDestroy(tmpBuf);
   207 	
   206 	
   208 	if(str.Length()>1)
   207 	if(str.Length()>1)
   209 		{
   208 		{
   210 		// chop away newlines at start
   209 		// chop away newlines at start