My company uses Zoom search for our recently-updated website, which runs on .NET 2.0. I used the method outlined on the Wrensoft site for running the cgi process and retrieving the search results, which works very well, but I ran into a problem with character sets. Non-standard characters like angled quotation marks and large dashes weren't decoding properly in the search result context, and changing the encoding in Zoom wasn't helping.
I realized that it might be a problem further down in the pipe, and came up with the following fix:
Notice the last two lines with the byte array and the Encoding. When I set the Zoom codepage to UTF-8, this now works perfectly. Don't forget to import System.Text either.
Enjoy!
I realized that it might be a problem further down in the pipe, and came up with the following fix:
Code:
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Diagnostics" %>
<%@ Import Namespace="System.Text" %>
<%@ Page Language="C#" %>
<%
string paramStr = "";
int parampos = Request.RawUrl.IndexOf("?");
if (parampos >= 0)
paramStr = Request.RawUrl.Substring(parampos + 1);
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = Server.MapPath("search.cgi");
psi.EnvironmentVariables["REQUEST_METHOD"] = "GET";
psi.EnvironmentVariables["QUERY_STRING"] = paramStr;
psi.RedirectStandardInput = false;
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
Process proc = Process.Start(psi);
proc.StandardOutput.ReadLine(); // skip the HTTP header line
string zoom_results = proc.StandardOutput.ReadToEnd(); // read from stdout
proc.WaitForExit();
byte[] bytes = proc.StandardOutput.CurrentEncoding.GetBytes(zoom_results);
// Print the output
Response.Write(Encoding.UTF8.GetString(bytes));
%>
Enjoy!
Comment