执行的Charset

时间:2013-01-20 21:10:06

标签: c# javascript

我的项目有问题。 我有一个js function sig7,它会产生哈希值。

html页面的字符集必须为utf-8

我尝试在带有库

C#应用中执行此js

一切正常,但生成的哈希无效。我认为这是因为代码的字符集不是utf-8

我的应用:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Noesis.Javascript;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            StreamReader sr = new StreamReader("c://lib.js");
            string script = sr.ReadToEnd();

            JavascriptContext context = new JavascriptContext();
            context.Run(script);
            var sig = context.Run(@"sig7('057d194dd856d4f8cd15bc85fbbddbf136df809f72f5a435e6af41c1f82f950f,Id166084073,ldsclldscl');").ToString();
            richTextBox1.Text = sig;
        }
    }
}

sig必须是1dbde1d62b6e0dca7d56f72e50c178132e236978d2dba1e2c3ada5b7b8973aeb,而不是我的应用生成的7211ed8fe85d750c26cb5abb499bfa88b7cecbe968fc6cc7efa69dc496c8ae12

任何帮助?

1 个答案:

答案 0 :(得分:1)

这一行:

var sig = context.Run(@"sig7('057d194dd856d4f8cd15bc85fbbddbf136df809f72f5a435e6af41c1f82f950f,Id166084073,ldsclldscl');").ToString();

是:

var sig = context.Run(@"sig7('057d194dd856d4f8cd15bc85fbbddbf136df809f72f5a435e6af41c1f82f950f', 'Id166084073', 'ldsclldscl');").ToString()